Skip to content

Instantly share code, notes, and snippets.

@dudelson
Created January 7, 2017 01:58
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 dudelson/dd155e8b29e95ba6cb1f4fcfbca37d6a to your computer and use it in GitHub Desktop.
Save dudelson/dd155e8b29e95ba6cb1f4fcfbca37d6a to your computer and use it in GitHub Desktop.
My solution for UVA 11991
#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