답안 #65875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65875 2018-08-09T05:05:28 Z ikura355 케이크 (CEOI14_cake) C++14
0 / 100
2000 ms 9848 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]--;
			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:39:8: warning: unused variable 'tmp' [-Wunused-variable]
    int tmp = a[x];
        ^~~
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 3 ms 248 KB Output is correct
2 Incorrect 2 ms 484 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2058 ms 1504 KB Time limit exceeded
2 Execution timed out 2067 ms 1800 KB Time limit exceeded
3 Execution timed out 2055 ms 2804 KB Time limit exceeded
4 Execution timed out 2066 ms 3140 KB Time limit exceeded
5 Execution timed out 2081 ms 3840 KB Time limit exceeded
6 Execution timed out 2078 ms 4260 KB Time limit exceeded
7 Execution timed out 2074 ms 4900 KB Time limit exceeded
8 Execution timed out 2070 ms 5216 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2061 ms 6020 KB Time limit exceeded
2 Execution timed out 2037 ms 6128 KB Time limit exceeded
3 Execution timed out 2019 ms 6228 KB Time limit exceeded
4 Incorrect 2 ms 6228 KB Output isn't correct
5 Execution timed out 2062 ms 6408 KB Time limit exceeded
6 Execution timed out 2062 ms 6492 KB Time limit exceeded
7 Execution timed out 2056 ms 6644 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 118 ms 6644 KB Output isn't correct
2 Correct 226 ms 6644 KB Output is correct
3 Execution timed out 2053 ms 6644 KB Time limit exceeded
4 Execution timed out 2063 ms 6644 KB Time limit exceeded
5 Incorrect 236 ms 6644 KB Output isn't correct
6 Execution timed out 2062 ms 6644 KB Time limit exceeded
7 Incorrect 1255 ms 7428 KB Output isn't correct
8 Execution timed out 2054 ms 7428 KB Time limit exceeded
9 Execution timed out 2069 ms 8224 KB Time limit exceeded
10 Incorrect 828 ms 8660 KB Output isn't correct
11 Execution timed out 2060 ms 9180 KB Time limit exceeded
12 Execution timed out 2054 ms 9816 KB Time limit exceeded
13 Execution timed out 2070 ms 9848 KB Time limit exceeded