44212023-03-27 19:01:15balaaaazsElőzésekcpp14Wrong answer 0/100589ms15720 KiB
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;

    vector<int> cars(n);
    for (int i = 0; i < n; i++) {
        cin >> cars[i];
    }

    unordered_map<int, int> overtakes;
    int leader = cars[0];
    for (int i = 0; i < q; i++) {
        int overtaken_car;
        cin >> overtaken_car;

        overtakes[cars[overtaken_car-1]]++;

        if (overtakes[cars[overtaken_car-1]] > overtakes[leader] ||
            (overtakes[cars[overtaken_car-1]] == overtakes[leader] && cars[overtaken_car-1] < leader)) {
            leader = cars[overtaken_car-1];
        }

        cout << leader << endl;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1688 KiB
subtask20/30
2Wrong answer3ms1928 KiB
3Wrong answer3ms2088 KiB
4Wrong answer4ms2372 KiB
5Wrong answer4ms2392 KiB
6Wrong answer6ms2760 KiB
7Wrong answer6ms2808 KiB
subtask30/70
8Wrong answer162ms5668 KiB
9Wrong answer365ms8408 KiB
10Wrong answer456ms9404 KiB
11Wrong answer222ms9488 KiB
12Wrong answer282ms10524 KiB
13Wrong answer481ms13772 KiB
14Wrong answer314ms14132 KiB
15Wrong answer395ms15232 KiB
16Wrong answer536ms15012 KiB
17Wrong answer405ms15452 KiB
18Wrong answer400ms15720 KiB
19Wrong answer229ms11620 KiB
20Wrong answer589ms15664 KiB
21Wrong answer370ms15292 KiB