답안 #65869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65869 2018-08-09T04:56:58 Z ikura355 케이크 (CEOI14_cake) C++14
0 / 100
2000 ms 33248 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;
				for(int i=st;i<=x;i++) mx = max(mx, a[i]);
				for(int i=st;i>=1;i--) {
					if(a[i]>mx) break;
					l = i;
				}
				printf("%d\n",x-l);
			}
			else {
				int mx = 0, r;
				for(int i=st;i>=x;i--) mx = max(mx, a[i]);
				for(int i=st;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(val<=a[i] && a[i]<=tmp) a[i]--;
			a[x] = n-val+1;
		}
	}
}

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);
               ~~~~~^~~~~~~~~~~~~~~~
cake.cpp:34:11: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
     printf("%d\n",r-x);
     ~~~~~~^~~~~~~~~~~~
cake.cpp:25:11: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
     printf("%d\n",x-l);
     ~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2028 ms 1372 KB Time limit exceeded
2 Execution timed out 2060 ms 2820 KB Time limit exceeded
3 Execution timed out 2059 ms 3484 KB Time limit exceeded
4 Execution timed out 2044 ms 5428 KB Time limit exceeded
5 Execution timed out 2059 ms 6164 KB Time limit exceeded
6 Execution timed out 2060 ms 6836 KB Time limit exceeded
7 Execution timed out 2082 ms 7384 KB Time limit exceeded
8 Execution timed out 2040 ms 8640 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2068 ms 10348 KB Time limit exceeded
2 Execution timed out 2053 ms 11648 KB Time limit exceeded
3 Execution timed out 2067 ms 12784 KB Time limit exceeded
4 Incorrect 3 ms 12784 KB Output isn't correct
5 Execution timed out 2070 ms 15044 KB Time limit exceeded
6 Execution timed out 2062 ms 17212 KB Time limit exceeded
7 Execution timed out 2066 ms 19256 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 446 ms 19256 KB Output isn't correct
2 Incorrect 772 ms 19256 KB Output isn't correct
3 Execution timed out 2047 ms 19768 KB Time limit exceeded
4 Execution timed out 2059 ms 20468 KB Time limit exceeded
5 Incorrect 917 ms 21472 KB Output isn't correct
6 Execution timed out 2062 ms 22196 KB Time limit exceeded
7 Execution timed out 2062 ms 22876 KB Time limit exceeded
8 Execution timed out 2084 ms 23820 KB Time limit exceeded
9 Execution timed out 2065 ms 26196 KB Time limit exceeded
10 Execution timed out 2064 ms 28860 KB Time limit exceeded
11 Execution timed out 2050 ms 28992 KB Time limit exceeded
12 Execution timed out 2031 ms 30940 KB Time limit exceeded
13 Execution timed out 2071 ms 33248 KB Time limit exceeded