fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. signed main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. int n, q;
  9. while (cin >> n >> q) {
  10. map<int, vector<int>> mp;
  11. for (int i = 0; i < n; i++) {
  12. int x;
  13. cin >> x;
  14. mp[x].push_back(i + 1);
  15. }
  16. while (q--) {
  17. int v, k;
  18. cin >> k >> v;
  19. if (k > mp[v].size())
  20. cout << 0 << "\n";
  21. else
  22. cout << mp[v][k - 1] << "\n";
  23. }
  24. }
  25. }
Success #stdin #stdout 0s 592KB
stdin
Standard input is empty
stdout
Standard output is empty