Submission #709067

#TimeUsernameProblemLanguageResultExecution timeMemory
709067vjudge1Abracadabra (CEOI22_abracadabra)C++17
10 / 100
255 ms12288 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1007; int n, q, a[N]; vector<int> g[N]; 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 <= 1000) { 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...