# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
676566 |
2022-12-31T09:52:16 Z |
vjudge1 |
Cake (CEOI14_cake) |
C++17 |
|
2000 ms |
2892 KB |
#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 1000000007
#define INF 10000000
#define ll long long
//#define cin fin
//#define cout fout
#define fi first
#define se second
using namespace std;
///ofstream fout("addictive.out");
///ifstream fin("addictive.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, a; cin >> n >> a; int arr[n], ans[n] = {};
for(int i = 0; i < n; i++) {
int x; cin >> x;
arr[i] = n-x+1;
}
int cnt = 1;
int l = a-2, r = a;
while(l >= 0 || r < n) {
if(r >= n) {
ans[l] = cnt;
cnt++;
l--;
}
else if(l < 0) {
ans[r] = cnt;
cnt++;
r++;
}
else if(arr[l] > arr[r]) {
ans[l] = cnt;
cnt++;
l--;
}
else {
ans[r] = cnt;
cnt++;
r++;
}
}
int q; cin >> q;
while(q--) {
char c; cin >> c;
if(c == 'E') {
int x, y; cin >> x >> y; x--;
for(int i = 0; i < n; i++) {
if(arr[i] < arr[x] && arr[i] >= y) {arr[i]++;}
}
arr[x] = y; cnt = 1; l = a-2; r = a;
while(l >= 0 || r < n)
{
if(r >= n)
{
ans[l] = cnt;
cnt++;
l--;
}
else if(l < 0)
{
ans[r] = cnt;
cnt++;
r++;
}
else if(arr[l] > arr[r])
{
ans[l] = cnt;
cnt++;
l--;
}
else
{
ans[r] = cnt;
cnt++;
r++;
}
}
}
else {
int x; cin >> x; cout << ans[x-1] << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
12 ms |
340 KB |
Output is correct |
5 |
Correct |
231 ms |
636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2068 ms |
460 KB |
Time limit exceeded |
2 |
Execution timed out |
2080 ms |
384 KB |
Time limit exceeded |
3 |
Execution timed out |
2076 ms |
340 KB |
Time limit exceeded |
4 |
Execution timed out |
2065 ms |
340 KB |
Time limit exceeded |
5 |
Execution timed out |
2086 ms |
468 KB |
Time limit exceeded |
6 |
Execution timed out |
2078 ms |
468 KB |
Time limit exceeded |
7 |
Execution timed out |
2080 ms |
468 KB |
Time limit exceeded |
8 |
Execution timed out |
2056 ms |
468 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
1552 KB |
Output is correct |
2 |
Correct |
44 ms |
1536 KB |
Output is correct |
3 |
Correct |
47 ms |
1604 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
112 ms |
2804 KB |
Output is correct |
6 |
Correct |
102 ms |
2892 KB |
Output is correct |
7 |
Correct |
77 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
348 ms |
652 KB |
Output is correct |
2 |
Correct |
564 ms |
748 KB |
Output is correct |
3 |
Execution timed out |
2068 ms |
1060 KB |
Time limit exceeded |
4 |
Execution timed out |
2016 ms |
856 KB |
Time limit exceeded |
5 |
Correct |
678 ms |
920 KB |
Output is correct |
6 |
Execution timed out |
2076 ms |
968 KB |
Time limit exceeded |
7 |
Execution timed out |
2085 ms |
920 KB |
Time limit exceeded |
8 |
Execution timed out |
2080 ms |
980 KB |
Time limit exceeded |
9 |
Execution timed out |
2036 ms |
2260 KB |
Time limit exceeded |
10 |
Execution timed out |
2051 ms |
1412 KB |
Time limit exceeded |
11 |
Execution timed out |
2091 ms |
1004 KB |
Time limit exceeded |
12 |
Execution timed out |
2080 ms |
2132 KB |
Time limit exceeded |
13 |
Execution timed out |
2064 ms |
2520 KB |
Time limit exceeded |