65792023-12-12 13:43:10batyuElőzésekcpp17Wrong answer 0/1003.099s6704 KiB
// Előzések.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
int find(int val, std::vector<int> vec)
{
    int i = 0;
    while (i < vec.size() && val != vec[i])
        i++;
    return i == vec.size() ? -1 : i;
}
int main()
{
    int N, Q;
    std::vector<int> sorrend;
    std::vector<int> elozesrend;
    std::cin >> N >> Q;
    int* elozesek = new int[N];

    for (int i = 0; i < N; i++)
    {
        int temp;
        std::cin >> temp;
        sorrend.push_back(temp);
        elozesek[i] = 0;
    }
    
    for (int i = 0; i < Q; i++)
    {
        int temp;
        std::cin >> temp;
        elozesrend.push_back(temp);
    }
    int maxi = 0;
    for (int i = 0; i < Q; i++)
    {
        //megelozi
        int ind = find(elozesrend[i], sorrend);
        int temp = sorrend[ind];
        sorrend[ind] = sorrend[ind - 1];
        sorrend[ind - 1] = temp;
        int megelozott = sorrend[ind];
        elozesek[megelozott]++;
        if (elozesek[maxi] < elozesek[megelozott])
            maxi = megelozott;
        else if (elozesek[maxi] == elozesek[megelozott])
            maxi = maxi > megelozott ? megelozott : maxi;
        //valasz
        std::cout << maxi << std::endl;
    }
    //delete[] elozesek;
}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1968 KiB
subtask20/30
2Wrong answer3ms2092 KiB
3Accepted3ms2156 KiB
4Accepted4ms2060 KiB
5Accepted6ms2368 KiB
6Accepted8ms2664 KiB
7Accepted8ms2912 KiB
subtask30/70
8Accepted1.539s4472 KiB
9Time limit exceeded3.099s3724 KiB
10Time limit exceeded3.062s4180 KiB
11Time limit exceeded3.071s4524 KiB
12Time limit exceeded3.078s4836 KiB
13Time limit exceeded3.039s5740 KiB
14Time limit exceeded3.082s5924 KiB
15Time limit exceeded3.066s6368 KiB
16Time limit exceeded3.059s6288 KiB
17Time limit exceeded3.055s6228 KiB
18Time limit exceeded3.048s6420 KiB
19Time limit exceeded3.059s6368 KiB
20Time limit exceeded3.046s6568 KiB
21Time limit exceeded3.071s6704 KiB