Submission #668596

#TimeUsernameProblemLanguageResultExecution timeMemory
668596ShahradAbracadabra (CEOI22_abracadabra)C++17
0 / 100
290 ms17692 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define endl '\n' #define pb push_back #define mk make_pair #define sz size() #define F first #define S second #define all(x) x.begin(), x.end() #define kill(x) return cout << x << endl, void(); #define int ll #define pii pair <int, int> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") //#pragma GCC target ("avx2") const int N = 2e5 + 5, M = 9e2 + 5; const int MOD = 998244353, INF = 2e9, sq = 300; int a[M][N]; int n; void merge (int x) { int l = 0, l2 = n / 2, l3 = 0; while (l < n / 2 && l2 < n) { if (a[x - 1][l] < a[x - 1][l2]) a[x][l3++] = a[x - 1][l++]; else a[x][l3++] = a[x - 1][l2++]; } while (l < n / 2) a[x][l3++] = a[x - 1][l++]; while (l2 < n) a[x][l3++] = a[x - 1][l2++]; } void Solve () { int q, t, x; cin >> n >> q; if (n > 1000) return; for (int i = 0; i < n; i++) cin >> a[0][i]; for (int i = 1; i < M; i++) merge (i); for (int i = 0; i < q; i++) { cin >> t >> x; cout << a[min (t, M - 1)][x - 1] << endl; } } int32_t main () { ios::sync_with_stdio (0), cin.tie (0), cout.tie (0); int tt = 1; // cin >> tt; while (tt--) Solve (); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...