44192023-03-27 18:57:41balaaaazsElőzésekcpp14Wrong answer 0/1003.072s10540 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 max_overtakes = 0, most_overtaken = -1;
    
    for (int i = 0; i < q; i++) {
        int overtaken_car;
        cin >> overtaken_car;
        
        int overtaking_car = cars[overtaken_car-2];
        
        overtakes[overtaking_car]++;
        if (overtakes[overtaking_car] > max_overtakes || 
            (overtakes[overtaking_car] == max_overtakes && overtaking_car < most_overtaken)) {
            max_overtakes = overtakes[overtaking_car];
            most_overtaken = overtaking_car;
        }
        
        cars.erase(cars.begin() + overtaken_car - 1);
        cars.insert(cars.begin() + overtaken_car - 2, overtaking_car);
        
        cout << most_overtaken << endl;
    }
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1684 KiB
subtask20/30
2Wrong answer3ms1932 KiB
3Wrong answer3ms2056 KiB
4Wrong answer4ms2168 KiB
5Wrong answer4ms2312 KiB
6Wrong answer6ms2668 KiB
7Wrong answer8ms2624 KiB
subtask30/70
8Wrong answer533ms4172 KiB
9Wrong answer1.328s6236 KiB
10Wrong answer1.843s6948 KiB
11Wrong answer1.481s8872 KiB
12Wrong answer2.039s9272 KiB
13Time limit exceeded3.026s10036 KiB
14Time limit exceeded3.055s6536 KiB
15Time limit exceeded3.072s6468 KiB
16Time limit exceeded3.061s6648 KiB
17Time limit exceeded3.069s6788 KiB
18Time limit exceeded3.069s6748 KiB
19Wrong answer2.447s10540 KiB
20Time limit exceeded3.033s6880 KiB
21Time limit exceeded3.071s7024 KiB