# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84022 | 2018-11-12T12:11:18 Z | Saboon | Cake (CEOI14_cake) | C++17 | 2000 ms | 3572 KB |
#include <bits/stdc++.h> #define MP make_pair #define F first #define PB push_back #define S second using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; const int maxn = 3e5 + 4; int a[maxn], pos[maxn]; int main (){ ios_base::sync_with_stdio(false); int n, st; scanf ("%d%d", &n, &st); for (int i = 1; i <= n; i++) { scanf ("%d", &a[i]); a[i] = n - a[i] + 1; } int ptr1 = st - 1, ptr2 = st + 1, tmp = 1; while (ptr1 >= 1 or ptr2 <= n) { if (ptr1 < 1) { pos[ptr2 ++] = tmp ++; } else if (ptr2 > n) { pos[ptr1 --] = tmp ++; } else { if (a[ptr1] > a[ptr2]) { pos[ptr1 --] = tmp ++; } else { pos[ptr2 ++] = tmp ++; } } } int m; scanf ("%d", &m); for (int i = 0; i < m; i++) { char type; scanf (" %c", &type); if (type == 'F') { int idx; scanf ("%d", &idx); printf ("%d\n", pos[idx]); } else { int idx, x; scanf ("%d%d", &idx, &x); for (int j = 1; j <= n; j++) { if (a[j] >= x and a[j] < a[idx]) { a[j] ++; } } a[idx] = x; int ptr1 = st - 1, ptr2 = st + 1, tmp = 1; while (ptr1 >= 1 or ptr2 <= n) { if (ptr1 < 1) { pos[ptr2 ++] = tmp ++; } else if (ptr2 > n) { pos[ptr1 --] = tmp ++; } else { if (a[ptr1] > a[ptr2]) { pos[ptr1 --] = tmp ++; } else { pos[ptr2 ++] = tmp ++; } } } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 3 ms | 444 KB | Output is correct |
4 | Correct | 18 ms | 624 KB | Output is correct |
5 | Correct | 294 ms | 828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2037 ms | 828 KB | Time limit exceeded |
2 | Execution timed out | 2050 ms | 828 KB | Time limit exceeded |
3 | Execution timed out | 2047 ms | 840 KB | Time limit exceeded |
4 | Execution timed out | 2061 ms | 840 KB | Time limit exceeded |
5 | Execution timed out | 2065 ms | 852 KB | Time limit exceeded |
6 | Execution timed out | 2069 ms | 872 KB | Time limit exceeded |
7 | Execution timed out | 2062 ms | 1000 KB | Time limit exceeded |
8 | Execution timed out | 2066 ms | 1000 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 2176 KB | Output is correct |
2 | Correct | 66 ms | 2176 KB | Output is correct |
3 | Correct | 65 ms | 2176 KB | Output is correct |
4 | Correct | 2 ms | 2176 KB | Output is correct |
5 | Correct | 165 ms | 3424 KB | Output is correct |
6 | Correct | 158 ms | 3572 KB | Output is correct |
7 | Correct | 112 ms | 3572 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 457 ms | 3572 KB | Output is correct |
2 | Correct | 771 ms | 3572 KB | Output is correct |
3 | Execution timed out | 2070 ms | 3572 KB | Time limit exceeded |
4 | Execution timed out | 2051 ms | 3572 KB | Time limit exceeded |
5 | Correct | 920 ms | 3572 KB | Output is correct |
6 | Execution timed out | 2076 ms | 3572 KB | Time limit exceeded |
7 | Execution timed out | 2078 ms | 3572 KB | Time limit exceeded |
8 | Execution timed out | 2059 ms | 3572 KB | Time limit exceeded |
9 | Execution timed out | 2053 ms | 3572 KB | Time limit exceeded |
10 | Execution timed out | 2072 ms | 3572 KB | Time limit exceeded |
11 | Execution timed out | 2069 ms | 3572 KB | Time limit exceeded |
12 | Execution timed out | 2059 ms | 3572 KB | Time limit exceeded |
13 | Execution timed out | 2068 ms | 3572 KB | Time limit exceeded |