#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
vector<int> c(n);
for (int i = 0; i < n; i++) {
cin >> c[i];
}
vector<int> freq(n, 0);
int max_freq = 0;
int max_freq_car = c[0];
for (int i = 0; i < q; i++) {
int car;
cin >> car;
freq[car-1]++;
if (freq[car-1] > max_freq || (freq[car-1] == max_freq && car < max_freq_car)) {
max_freq = freq[car-1];
max_freq_car = car;
}
cout << max_freq_car << endl;
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1812 KiB | ||||
subtask2 | 0/30 | ||||||
2 | Wrong answer | 3ms | 2052 KiB | ||||
3 | Wrong answer | 3ms | 2300 KiB | ||||
4 | Wrong answer | 4ms | 2564 KiB | ||||
5 | Wrong answer | 4ms | 2760 KiB | ||||
6 | Wrong answer | 6ms | 2812 KiB | ||||
7 | Wrong answer | 8ms | 2976 KiB | ||||
subtask3 | 0/70 | ||||||
8 | Wrong answer | 254ms | 3672 KiB | ||||
9 | Wrong answer | 344ms | 4352 KiB | ||||
10 | Wrong answer | 421ms | 4776 KiB | ||||
11 | Wrong answer | 273ms | 5644 KiB | ||||
12 | Wrong answer | 210ms | 5752 KiB | ||||
13 | Wrong answer | 275ms | 6244 KiB | ||||
14 | Wrong answer | 428ms | 6660 KiB | ||||
15 | Wrong answer | 338ms | 6836 KiB | ||||
16 | Wrong answer | 337ms | 6836 KiB | ||||
17 | Wrong answer | 527ms | 6896 KiB | ||||
18 | Wrong answer | 377ms | 7032 KiB | ||||
19 | Wrong answer | 202ms | 6920 KiB | ||||
20 | Wrong answer | 377ms | 6792 KiB | ||||
21 | Wrong answer | 527ms | 6908 KiB |