Submission #772793

#TimeUsernameProblemLanguageResultExecution timeMemory
772793Valters07Abracadabra (CEOI22_abracadabra)C++14
10 / 100
652 ms26820 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #define fio ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define en cin.close();return 0; #define pb push_back #define fi first//printf("%lli\n",cur); #define se second//scanf("%lli",&n); using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1005; vector<pair<int,int> > qu[N]; vector<int> make_op(vector<int> &a) { int n = a.size(); vector<int> ret; int it = 0, it2 = n/2; while(it<n/2||it2<n) { if(it==n/2) ret.pb(a[it2++]); else if(it2==n) ret.pb(a[it++]); else if(a[it]<a[it2]) ret.pb(a[it++]); else ret.pb(a[it2++]); } return ret; } int main() { fio // ifstream cin("in.in"); int n, q; cin >> n >> q; vector<int> a(n), ans(q); for(auto &x:a) cin >> x; for(int qi = 0;qi<q;qi++) { int t, x; cin >> t >> x; qu[min(t,N-1)].pb({x,qi}); } for(int i = 0;i<N;i++) { for(auto x:qu[i]) ans[x.se]=a[x.fi-1]; a = make_op(a); } for(auto x:ans) cout << x << "\n"; // cin.close(); 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...