Skip to content

Instantly share code, notes, and snippets.

@s25g5d4
Last active August 29, 2015 14:22
Show Gist options
  • Save s25g5d4/1fa1e5897147c5efc0f9 to your computer and use it in GitHub Desktop.
Save s25g5d4/1fa1e5897147c5efc0f9 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
int main()
{
using namespace std;
while (true) {
int n, m;
cin >> n >> m;
if (cin.eof())
break;
vector<vector<int>> occurence(1000000);
int i = 0;
while (n--) {
int u;
cin >> u;
--u;
occurence[u].push_back(++i);
}
while (m--) {
unsigned int k, v;
cin >> k >> v;
--k;
--v;
if (occurence[v].size() <= k)
cout << '0' << endl;
else
cout << occurence[v][k] << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment