Created
January 7, 2017 01:58
-
-
Save dudelson/dd155e8b29e95ba6cb1f4fcfbca37d6a to your computer and use it in GitHub Desktop.
My solution for UVA 11991
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
#define maxn (int)(1e6)+1 | |
vector< vector<int> > a(maxn); | |
int n, m, k, v; | |
int main() { | |
while(cin >> n >> m) { | |
fill(a.begin(), a.end(), vector<int>()); | |
for(int i=0; i<n; i++) { | |
int x; | |
cin >> x; | |
a[x].push_back(i+1); | |
} | |
for(int i=0; i<m; i++) { | |
cin >> k >> v; | |
if(k > (int)a[v].size()) cout << "0\n"; | |
else cout << a[v][k-1] << '\n'; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment