Submit | All submissions | Best solutions | Back to list |
Problem hidden
PERMUN - Permutation |
You will be given a permutation of first N natural numbers.Then you will be asked to print the smallest index of the array which contains the number between a given range(inclusive).Refer Iput-Output for more details.
Input
First line contains two integers N and Q separated by a space.
Second line contains N integers separeted by a space.(From 1 to N in any order)
Now Q line follows :Each line contains two integers A and B separated by space.
Output
You must Output exactly Q lines each containg the answer.
Constraint:
N<=100000,Q<=100000,A<=B<=100000.
Example
Input:
2 2 2 1 1 2 1 12 22 1
Output: 1 2
Added by: | devu |
Date: | 2012-08-14 |
Time limit: | 0.105s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM32-GCC ASM64 MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET |
Resource: | Surendra Baswana |