65762023-12-12 13:05:45batyuElőzésekcpp17Time limit exceeded 30/1003.082s32900 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);
    }
    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;
        elozesek[sorrend[ind]]++;
        //valasz
        int maxi = 0;
        for (int j = 0; j < N; j++)
        {
            if (elozesek[j] > elozesek[maxi])
                maxi = j;
        }
        std::cout << maxi << std::endl;
    }

}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
subtask230/30
2Accepted3ms2060 KiB
3Accepted3ms2276 KiB
4Accepted8ms2508 KiB
5Accepted9ms2492 KiB
6Accepted25ms2516 KiB
7Accepted25ms2848 KiB
subtask30/70
8Time limit exceeded3.059s3732 KiB
9Time limit exceeded3.071s5504 KiB
10Time limit exceeded3.075s7216 KiB
11Time limit exceeded3.045s8792 KiB
12Time limit exceeded3.075s10548 KiB
13Time limit exceeded3.059s13032 KiB
14Time limit exceeded3.038s15636 KiB
15Time limit exceeded3.053s18492 KiB
16Time limit exceeded3.082s20740 KiB
17Time limit exceeded3.078s23568 KiB
18Time limit exceeded3.062s26128 KiB
19Time limit exceeded3.071s28060 KiB
20Time limit exceeded3.072s30332 KiB
21Time limit exceeded3.042s32900 KiB