Submission #709072

#TimeUsernameProblemLanguageResultExecution timeMemory
709072vjudge1Abracadabra (CEOI22_abracadabra)C++17
0 / 100
161 ms163428 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 7; int n, q, a[N]; vector<int> g[101]; signed main () { ios_base::sync_with_stdio(NULL); cin.tie(0), cout.tie(0); cin >> n >> q; int lol = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; g[lol].push_back(a[i]); } while (lol <= 100) { lol++; int l = 0, r = n/2; while (l < n/2 || r < n) { if (l == n/2) { g[lol].push_back(g[lol-1][r]); r++; continue; } if (r == n) { g[lol].push_back(g[lol-1][l]); l++; continue; } if (g[lol-1][l] <= g[lol-1][r]) { g[lol].push_back(g[lol-1][l]); l++; } else { g[lol].push_back(g[lol-1][r]); r++; } } if (g[lol] == g[lol-1]) break; } while (q--) { int i, j; cin >> i >> j; cout << g[min(lol, i)][j-1] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...