# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
65895 | 2018-08-09T05:38:49 Z | ikura355 | 케이크 (CEOI14_cake) | C++14 | 2000 ms | 3132 KB |
#include<bits/stdc++.h> using namespace std; const int maxn = 250000 + 5; int n,st,q; int a[maxn]; int pos[maxn]; int main() { scanf("%d%d",&n,&st); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++) pos[n-a[i]+1] = i; scanf("%d",&q); while(q--) { char type; scanf(" %c",&type); if(type=='F') { int x; scanf("%d",&x); if(x==st) printf("0\n"); else if(x>st) { int mx = 0, l = st; for(int i=st+1;i<=x;i++) mx = max(mx, a[i]); for(int i=st-1;i>=1;i--) { if(a[i]>mx) break; l = i; } printf("%d\n",x-l); } else { int mx = 0, r = st; for(int i=st-1;i>=x;i--) mx = max(mx, a[i]); for(int i=st+1;i<=n;i++) { if(a[i]>mx) break; r = i; } printf("%d\n",r-x); } } else { int x,ra; scanf("%d%d",&x,&ra); for(int i=ra-1;i>=1;i--) a[pos[i]]++; a[x] = a[pos[ra]]+1; int hey = 15; for(int i=1;i<=15;i++) if(pos[i]==x) hey = i; for(int i=hey;i>=ra;i--) pos[i] = pos[i-1]; pos[ra] = x; // for(int i=1;i<=n;i++) printf("%d ",pos[i]); // printf("\n"); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 5 ms | 488 KB | Output is correct |
5 | Correct | 28 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 165 ms | 592 KB | Output is correct |
2 | Correct | 206 ms | 656 KB | Output is correct |
3 | Correct | 145 ms | 656 KB | Output is correct |
4 | Correct | 173 ms | 656 KB | Output is correct |
5 | Correct | 171 ms | 756 KB | Output is correct |
6 | Correct | 163 ms | 756 KB | Output is correct |
7 | Correct | 179 ms | 812 KB | Output is correct |
8 | Correct | 146 ms | 812 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2054 ms | 1944 KB | Time limit exceeded |
2 | Execution timed out | 2052 ms | 1944 KB | Time limit exceeded |
3 | Execution timed out | 2061 ms | 1944 KB | Time limit exceeded |
4 | Correct | 3 ms | 1944 KB | Output is correct |
5 | Execution timed out | 2051 ms | 2948 KB | Time limit exceeded |
6 | Execution timed out | 2064 ms | 2988 KB | Time limit exceeded |
7 | Execution timed out | 2041 ms | 3044 KB | Time limit exceeded |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 3044 KB | Output is correct |
2 | Correct | 80 ms | 3044 KB | Output is correct |
3 | Correct | 827 ms | 3044 KB | Output is correct |
4 | Correct | 894 ms | 3044 KB | Output is correct |
5 | Correct | 166 ms | 3044 KB | Output is correct |
6 | Execution timed out | 2033 ms | 3044 KB | Time limit exceeded |
7 | Correct | 586 ms | 3044 KB | Output is correct |
8 | Correct | 169 ms | 3044 KB | Output is correct |
9 | Execution timed out | 2044 ms | 3048 KB | Time limit exceeded |
10 | Correct | 385 ms | 3048 KB | Output is correct |
11 | Execution timed out | 2074 ms | 3048 KB | Time limit exceeded |
12 | Execution timed out | 2067 ms | 3048 KB | Time limit exceeded |
13 | Execution timed out | 2066 ms | 3132 KB | Time limit exceeded |