0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:52:02 +00:00

C - The Kth Time Query

https://atcoder.jp/contests/abc235/submissions/28548889
This commit is contained in:
Baoshuo Ren 2022-01-15 20:33:27 +08:00
parent 20c8c20afb
commit 3f3a5b9423
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

28
AtCoder/ABC235/C/C.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <iostream>
#include <unordered_map>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
int n, q, a, x, k;
std::unordered_map<int, std::vector<int>> map;
int main() {
std::ios::sync_with_stdio(false);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a;
map[a].push_back(i);
}
while (q--) {
cin >> x >> k;
if (!map.count(x) || map[x].size() < k) {
cout << -1 << endl;
} else {
cout << map[x][k - 1] << endl;
}
}
return 0;
}