Submission #933597

#TimeUsernameProblemLanguageResultExecution timeMemory
933597ezzzayAbracadabra (CEOI22_abracadabra)C++14
10 / 100
1463 ms524288 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back const int N=1e4; int n,q; vector<vector<int>>v; map<int,vector<int>>mp; vector<int>ans; signed main(){ cin>>n>>q; vector<int>vc; for(int i=1;i<=n;i++){ int a; cin>>a; vc.pb(a); } mp[0]=vc; int y=0; for(int l=1;l<=n;l++){ vc=mp[l-1]; vector<int>vec; int i = 0, j = n/2; while(i<n/2 and j<n){ if(vc[i]<vc[j]){ vec.pb(vc[i++]); } else{ vec.pb(vc[j++]); } } while(i<n/2){ vec.pb(vc[i++]); } while(j<n)vec.pb(vc[j++]); mp[l]=vec; y=l; if(mp[l]==mp[l-1])break; } while(q--){ int t,idx; cin>>t>>idx; idx--; if(t>y)t=y; ans.pb(mp[t][idx]); } for(auto a:ans)cout<<a<<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...