Submission #643139

#TimeUsernameProblemLanguageResultExecution timeMemory
643139elifAbracadabra (CEOI22_abracadabra)C++17
0 / 100
3034 ms19832 KiB
#include <bits/stdc++.h> using namespace std; #define N 10003 int main(){ ios_base::sync_with_stdio(0); int n, q; cin >> n >> q; vector<int> a(n), ans; for(int i=0; i<n; i++) cin >> a[i]; vector<pair<int, int>> qs(q); for(int i=0; i<q; i++){ cin >> qs[i].first; cin >> qs[i].second; } int qt = qs[0].first; if(qt >= N) qt = N - 1; 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++; } if(qt == cnt) ans = a; } for(int i=0; i<q; i++){ int ind = qs[i].second; cout << ans[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...