제출 #1189372

#제출 시각아이디문제언어결과실행 시간메모리
1189372UnforgettableplAbracadabra (CEOI22_abracadabra)C++20
0 / 100
651 ms589824 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,Q;
    cin >> N >> Q;
    int MAX_ROUNDS = N;
    vector<vector<int>> round(MAX_ROUNDS+1);
    for(int i=1;i<=N;i++){
        int x;cin>>x;
        round[0].emplace_back(x);
    }
    int transfers = 0;
    for(int r=1;r<=MAX_ROUNDS;r++){
        int left = 0;
        int right = N/2;
        while(left<N/2 and right<N){
            if(round[r-1][left]<round[r-1][right]){
                round[r].emplace_back(round[r-1][left++]);
            } else {
                transfers++;
                round[r].emplace_back(round[r-1][right++]);
            }
        }
        while(left<N/2){
            round[r].emplace_back(round[r-1][left++]);
        }
        while(right<N){
            round[r].emplace_back(round[r-1][right++]); 
        }
    }
    assert(transfers<=100*N);
    for(int i=1;i<=Q;i++){
        int t,x;cin>>t>>x;
        t = min(t,MAX_ROUNDS);
        cout << round[t][x-1] << '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...