fork(1) download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define int long long
  4. #define endl '\n'
  5. #define all(s) s.begin(),s.end()
  6. #define gre(v) sort(all(v),greater<>());
  7. #define rep(i,n) for(int i=0;i<(n);i++)//0-indexed
  8. #define ull unsigned long long
  9. // #define NDEBUG
  10. #define loop(a,b) for(int i=a;i<=b;i++)
  11. #define format(n) fixed<<setprecision(n)
  12. // Matrix vector<vector<data type>>a(r,vector<data type>(c));
  13. #define AYAA ios_base::sync_with_stdio(false); cout.tie(0);
  14. using namespace std;
  15. int fx[]={0,-1,0,1};
  16. int fy[]={1,0,-1,0};
  17.  
  18.  
  19.  
  20.  
  21. int32_t main() {
  22. #ifndef ONLINE_JUDGE
  23. freopen("Input.txt","r",stdin);
  24. freopen("Output.txt","w",stdout);
  25. #endif
  26. AYAA
  27.  
  28.  
  29.  
  30.  
  31. int t=1;
  32. //cin>>t;
  33. while(t--) {
  34. int n,m;
  35. while(cin>>n>>m) {
  36. vector<vector<int>> adj(n+1);
  37. for (int i = 0; i < n; i++) {
  38. int x;
  39. cin >> x;
  40. adj[x].push_back(i);
  41. }
  42. while (m--) {
  43. int u, v;
  44. cin >> u >> v;
  45. u--;
  46.  
  47. if (adj[v].size() <= u)cout << 0 << endl;
  48. else cout << adj[v][u] + 1 << endl;
  49.  
  50. }
  51. }
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. return 0;
  65. }
Success #stdin #stdout 0.01s 5300KB
stdin
Standard input is empty
stdout
Standard output is empty