답안 #65873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65873 2018-08-09T05:01:57 Z ikura355 케이크 (CEOI14_cake) C++14
15 / 100
2000 ms 2440 KB
#include<bits/stdc++.h>
using namespace std;

const int maxn = 250000 + 5;

int n,st,q;
int a[maxn];

int main() {
	scanf("%d%d",&n,&st);
	for(int i=1;i<=n;i++) scanf("%d",&a[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,val; scanf("%d%d",&x,&val);
			int tmp = a[x];
			for(int i=1;i<=n;i++) if(n-val+1>=a[i] && a[i]>=tmp) a[i]--;
			a[x] = n-val+1;
//			for(int i=1;i<=n;i++) printf("%d ",a[i]);
//			printf("\n");
		}
	}
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&st);
  ~~~~~^~~~~~~~~~~~~~~
cake.cpp:11:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                        ~~~~~^~~~~~~~~~~~
cake.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ~~~~~^~~~~~~~~
cake.cpp:14:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   char type; scanf(" %c",&type);
              ~~~~~^~~~~~~~~~~~~
cake.cpp:16:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int x; scanf("%d",&x);
           ~~~~~^~~~~~~~~
cake.cpp:38:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int x,val; scanf("%d%d",&x,&val);
               ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 4 ms 408 KB Output is correct
4 Correct 17 ms 600 KB Output is correct
5 Correct 219 ms 728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2050 ms 748 KB Time limit exceeded
2 Execution timed out 2072 ms 876 KB Time limit exceeded
3 Execution timed out 2073 ms 884 KB Time limit exceeded
4 Execution timed out 2069 ms 884 KB Time limit exceeded
5 Execution timed out 2072 ms 884 KB Time limit exceeded
6 Execution timed out 2066 ms 884 KB Time limit exceeded
7 Execution timed out 2064 ms 884 KB Time limit exceeded
8 Execution timed out 2040 ms 884 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2073 ms 1576 KB Time limit exceeded
2 Execution timed out 2073 ms 1624 KB Time limit exceeded
3 Execution timed out 2066 ms 1916 KB Time limit exceeded
4 Correct 2 ms 1916 KB Output is correct
5 Execution timed out 2056 ms 2440 KB Time limit exceeded
6 Execution timed out 2060 ms 2440 KB Time limit exceeded
7 Execution timed out 2076 ms 2440 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 349 ms 2440 KB Output is correct
2 Correct 564 ms 2440 KB Output is correct
3 Execution timed out 2057 ms 2440 KB Time limit exceeded
4 Execution timed out 2060 ms 2440 KB Time limit exceeded
5 Correct 736 ms 2440 KB Output is correct
6 Execution timed out 2078 ms 2440 KB Time limit exceeded
7 Execution timed out 2045 ms 2440 KB Time limit exceeded
8 Execution timed out 2064 ms 2440 KB Time limit exceeded
9 Execution timed out 2064 ms 2440 KB Time limit exceeded
10 Execution timed out 2057 ms 2440 KB Time limit exceeded
11 Execution timed out 2064 ms 2440 KB Time limit exceeded
12 Execution timed out 2060 ms 2440 KB Time limit exceeded
13 Execution timed out 2062 ms 2440 KB Time limit exceeded