Submission #65871

# Submission time Handle Problem Language Result Execution time Memory
65871 2018-08-09T04:59:06 Z ikura355 Cake (CEOI14_cake) C++14
0 / 100
2000 ms 5824 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(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);
               ~~~~~^~~~~~~~~~~~~~~~
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);
     ~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 3 ms 484 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2071 ms 1224 KB Time limit exceeded
2 Execution timed out 2052 ms 1976 KB Time limit exceeded
3 Execution timed out 2041 ms 2668 KB Time limit exceeded
4 Execution timed out 2057 ms 2820 KB Time limit exceeded
5 Execution timed out 2040 ms 3140 KB Time limit exceeded
6 Execution timed out 2041 ms 3396 KB Time limit exceeded
7 Execution timed out 2061 ms 3776 KB Time limit exceeded
8 Execution timed out 2037 ms 3984 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2066 ms 4624 KB Time limit exceeded
2 Execution timed out 2058 ms 4624 KB Time limit exceeded
3 Execution timed out 2057 ms 4828 KB Time limit exceeded
4 Incorrect 2 ms 4828 KB Output isn't correct
5 Execution timed out 2047 ms 5336 KB Time limit exceeded
6 Execution timed out 2051 ms 5336 KB Time limit exceeded
7 Execution timed out 2037 ms 5360 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 358 ms 5360 KB Output isn't correct
2 Incorrect 574 ms 5360 KB Output isn't correct
3 Execution timed out 2061 ms 5360 KB Time limit exceeded
4 Execution timed out 2064 ms 5360 KB Time limit exceeded
5 Incorrect 718 ms 5360 KB Output isn't correct
6 Execution timed out 2061 ms 5360 KB Time limit exceeded
7 Execution timed out 2040 ms 5360 KB Time limit exceeded
8 Execution timed out 2044 ms 5360 KB Time limit exceeded
9 Execution timed out 2059 ms 5360 KB Time limit exceeded
10 Execution timed out 2049 ms 5692 KB Time limit exceeded
11 Execution timed out 2041 ms 5692 KB Time limit exceeded
12 Execution timed out 2068 ms 5692 KB Time limit exceeded
13 Execution timed out 2020 ms 5824 KB Time limit exceeded