제출 #848498

#제출 시각아이디문제언어결과실행 시간메모리
848498BenmathAbracadabra (CEOI22_abracadabra)C++14
10 / 100
1526 ms524288 KiB
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; int main() { int n,q; cin>>n>>q; int arr[n]; for(int i=0;i<n;i++){ cin>>arr[i]; } vector<int>v[n+2]; for(int i=0;i<n;i++){ v[0].push_back(arr[i]); } for(int j=1;j<=n;j++){ int prvi=0; int drugi=n/2; int t1=0; while(t1==0){ if(prvi<n/2 and drugi<n){ if(v[j-1][prvi]>v[j-1][drugi]){ v[j].push_back(v[j-1][drugi]); drugi++; }else{ v[j].push_back(v[j-1][prvi]); prvi++; } }else{ if(prvi>=n/2){ if(drugi>=n){ t1++; break; }else{ v[j].push_back(v[j-1][drugi]); drugi++; } }else{ v[j].push_back(v[j-1][prvi]); prvi++; } } } } while(q--){ int t,i; cin>>t>>i; i--; if(t<=n){ cout<<v[t][i]<<endl; }else{ cout<<v[n][i]<<endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...