# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
798115 | 2023-07-30T11:27:45 Z | IvanJ | Abracadabra (CEOI22_abracadabra) | C++17 | 3000 ms | 31348 KB |
#include<bits/stdc++.h> #define pb push_back #define x first #define y second #define all(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 2e5 + 5, maxq = 1e6 + 5; int n, q; int p[maxn]; int ans[maxq]; vector<ii> qs[maxn]; vector<int> get(vector<int> L, vector<int> R) { int i = 0, j = 0; vector<int> ret; while(i < (n / 2) || j < (n / 2)) { if(i == n / 2) ret.pb(R[j++]); else if(j == n / 2) ret.pb(L[i++]); else { if(L[i] < R[j]) ret.pb(L[i++]); else ret.pb(R[j++]); } } return ret; } int main() { scanf("%d%d", &n, &q); for(int i = 0;i < n;i++) scanf("%d", p + i); for(int i = 0;i < q;i++) { int t, x; scanf("%d%d", &t, &x); x--; qs[min(t, n)].pb({x, i}); } for(int t = 0;t <= n;t++) { for(ii qi : qs[t]) ans[qi.y] = p[qi.x]; vector<int> L, R; for(int i = 0;i < n / 2;i++) L.pb(p[i]); for(int i = n / 2;i < n;i++) R.pb(p[i]); vector<int> v = get(L, R); for(int i = 0;i < n;i++) p[i] = v[i]; } for(int i = 0;i < q;i++) printf("%d\n", ans[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 237 ms | 23040 KB | Output is correct |
2 | Correct | 214 ms | 29156 KB | Output is correct |
3 | Correct | 218 ms | 28840 KB | Output is correct |
4 | Correct | 201 ms | 26548 KB | Output is correct |
5 | Correct | 217 ms | 30640 KB | Output is correct |
6 | Correct | 201 ms | 30508 KB | Output is correct |
7 | Correct | 225 ms | 31348 KB | Output is correct |
8 | Correct | 202 ms | 28972 KB | Output is correct |
9 | Correct | 203 ms | 28272 KB | Output is correct |
10 | Correct | 200 ms | 27860 KB | Output is correct |
11 | Correct | 206 ms | 28212 KB | Output is correct |
12 | Correct | 192 ms | 25608 KB | Output is correct |
13 | Correct | 202 ms | 27056 KB | Output is correct |
14 | Correct | 203 ms | 29900 KB | Output is correct |
15 | Correct | 210 ms | 27876 KB | Output is correct |
16 | Correct | 6 ms | 4948 KB | Output is correct |
17 | Correct | 199 ms | 25880 KB | Output is correct |
18 | Correct | 215 ms | 25756 KB | Output is correct |
19 | Correct | 2 ms | 5012 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3051 ms | 16996 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3034 ms | 9876 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 237 ms | 23040 KB | Output is correct |
2 | Correct | 214 ms | 29156 KB | Output is correct |
3 | Correct | 218 ms | 28840 KB | Output is correct |
4 | Correct | 201 ms | 26548 KB | Output is correct |
5 | Correct | 217 ms | 30640 KB | Output is correct |
6 | Correct | 201 ms | 30508 KB | Output is correct |
7 | Correct | 225 ms | 31348 KB | Output is correct |
8 | Correct | 202 ms | 28972 KB | Output is correct |
9 | Correct | 203 ms | 28272 KB | Output is correct |
10 | Correct | 200 ms | 27860 KB | Output is correct |
11 | Correct | 206 ms | 28212 KB | Output is correct |
12 | Correct | 192 ms | 25608 KB | Output is correct |
13 | Correct | 202 ms | 27056 KB | Output is correct |
14 | Correct | 203 ms | 29900 KB | Output is correct |
15 | Correct | 210 ms | 27876 KB | Output is correct |
16 | Correct | 6 ms | 4948 KB | Output is correct |
17 | Correct | 199 ms | 25880 KB | Output is correct |
18 | Correct | 215 ms | 25756 KB | Output is correct |
19 | Correct | 2 ms | 5012 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Execution timed out | 3051 ms | 16996 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |