Skip to content

Instantly share code, notes, and snippets.

@joaogui1
Created April 25, 2016 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaogui1/3b2732bcb40d23aac325963061d0a95d to your computer and use it in GitHub Desktop.
Save joaogui1/3b2732bcb40d23aac325963061d0a95d to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <cstdlib>
#include <vector>
#define MAXN 1000010
using namespace std;
vector <int> G[MAXN];
int main(){
int n, m, k, v, a;
while(scanf("%d%d", &n, &m) != EOF){
for(int i = 1; i<=MAXN; i++)
G[i].clear();
for(int i = 1; i <= n; i++){
scanf("%d", &a);
G[a].push_back(i);
}
for(int i = 1; i <= m; i++){
scanf("%d%d", &k, &v);
k--;
if(k >= G[v].size())
printf("0\n");
else
printf("%d\n", G[v][k]);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment