65782023-12-12 13:42:48batyuElőzésekcpp17Wrong answer 0/1003.082s6512 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;
    }
    for (int i = 0; i < N; i++)
        std::cout << elozesek[i];
    //delete[] elozesek;
}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1684 KiB
subtask20/30
2Wrong answer3ms1932 KiB
3Wrong answer3ms2056 KiB
4Wrong answer4ms2288 KiB
5Wrong answer4ms2388 KiB
6Wrong answer7ms2468 KiB
7Wrong answer7ms2472 KiB
subtask30/70
8Wrong answer1.519s4076 KiB
9Time limit exceeded3.046s3284 KiB
10Time limit exceeded3.082s3884 KiB
11Time limit exceeded3.053s4036 KiB
12Time limit exceeded3.058s4500 KiB
13Time limit exceeded3.071s5176 KiB
14Time limit exceeded3.071s5668 KiB
15Time limit exceeded3.075s6004 KiB
16Time limit exceeded3.046s6008 KiB
17Time limit exceeded3.052s6340 KiB
18Time limit exceeded3.063s6448 KiB
19Time limit exceeded3.039s6280 KiB
20Time limit exceeded3.062s6392 KiB
21Time limit exceeded3.062s6512 KiB