Submission #739626

#TimeUsernameProblemLanguageResultExecution timeMemory
739626danikoynovAbracadabra (CEOI22_abracadabra)C++14
10 / 100
3071 ms31372 KiB
/** ____ ____ ____ ____ ____ ____ ||l |||e |||i |||n |||a |||d || ||__|||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\|/__\| **/ #include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 2e5 + 10, maxq = 1e6 + 10; int n, q, a[maxn], ans[maxq]; vector < pair < int, int > > ask[maxn]; void shuffle_array() { deque < int > d1, d2; for (int i = 1; i <= n / 2; i ++) d1.push_back(a[i]); for (int i = n / 2 + 1; i <= n; i ++) d2.push_back(a[i]); deque < int > res; while(!d1.empty() && !d2.empty()) { if (d1.front() < d2.front()) { res.push_back(d1.front()); d1.pop_front(); } else { res.push_back(d2.front()); d2.pop_front(); } } while(!d1.empty()) { res.push_back(d1.front()); d1.pop_front(); } while(!d2.empty()) { res.push_back(d2.front()); d2.pop_front(); } for (int i = 1; i <= n; i ++) a[i] = res[i - 1]; } void solve() { cin >> n >> q; for (int i = 1; i <= n; i ++) { cin >> a[i]; } for (int i = 1; i <= q; i ++) { int t, v; cin >> t >> v; t = min(t, n); ask[t].push_back({v, i}); } for (int f = 0; f <= n; f ++) { for (pair < int, int > cur : ask[f]) { ans[cur.second] = a[cur.first]; } /**for (int i = 1; i <= n; i ++) cout << a[i] << " "; cout << endl;*/ shuffle_array(); } for (int i = 1; i <= q; i ++) cout << ans[i] << endl; } int main() { solve(); 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...