Submission #1186767

#TimeUsernameProblemLanguageResultExecution timeMemory
1186767GrayAbracadabra (CEOI22_abracadabra)C++20
10 / 100
471 ms589824 KiB
#include <algorithm> #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define ff first #define ss second #define ln "\n" #define mp make_pair #define pb push_back #define INF (ll)2e18 #define MOD (ll)(1e9+7) void solve(){ ll n, q; cin >> n >> q; vector<ll> a(n); for (ll i=0; i<n; i++) cin >> a[i]; vector<vector<ll>> res; res.push_back(a); while (1){ vector<ll> nw; ll l=0, r=n/2; while (l<n/2 or r<n){ if (l<n/2 and (r==n or res.back()[l]<res.back()[r])){ nw.push_back(res.back()[l]); l++; }else{ nw.push_back(res.back()[r]); r++; } } if (nw==res.back()) break; res.push_back(nw); } while (q--){ ll t, i; cin >> t >> i; i--; t=min(t, (ll)res.size()-1); cout << res[t][i] << ln; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef LOCAL auto start = chrono::high_resolution_clock::now(); #endif ll t=1; // cin >> t; for (ll __c=1; __c<=t; __c++) solve(); #ifdef LOCAL auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start); cout << setprecision(0) << fixed << "time: " << (double)duration.count()/1000.0 << " milliseconds" << endl; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...