Submission #643132

#TimeUsernameProblemLanguageResultExecution timeMemory
643132elifAbracadabra (CEOI22_abracadabra)C++17
0 / 100
403 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #define N 200005 int main(){ ios_base::sync_with_stdio(0); int n, q; cin >> n >> q; vector<int> a(n); for(int i=0; i<n; i++) cin >> a[i]; map<int, vector<int>> mp; mp[0] = a; for(int cnt=1; cnt<N; cnt++){ int i = 0; int j = n/2; vector<int> v = a; int k = 0; while(i < n/2 && j < n){ if(v[i] < v[j]){ a[k] = v[i]; k++, i++; } else{ a[k] = v[j]; k++, j++; } } while(i < n/2){ a[k] = v[i]; k++, i++; } while(j < n/2){ a[k] = v[j]; k++, j++; } /* cout << "ARRAY:" << endl; for(auto x : a) cout << x << " "; cout << endl; cout << endl; */ mp[cnt] = a; } for(int i=0; i<q; i++){ int t, ind; cin >> t >> ind; if(t >= N) t = N-5; // cout << i << "th test: "; cout << mp[t][ind-1] << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...