답안 #25953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25953 2017-06-25T07:59:24 Z 서규호(#1088) 케이크 (CEOI14_cake) C++14
0 / 100
2000 ms 5592 KB
#include <bits/stdc++.h>

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 1000000007
#define left lleft
#define right rright
#define INF 2000000000
#define Linf 1000000000000000000LL
#define next nnext
#define minus mminus

using namespace std;

int N,M,Q,K;
int a[250002],ans[250002];
vector<int> X;

void process(){
	int l,r;
	l = M; r = M;
	while(r-l != N+1){
		if(l == 0 || (r != N && a[r+1] < a[l-1])){
			r++;
			ans[r] = r-l;
		}else{
			l--;
			ans[l] = r-l;
		}
	}
}

int main(){
	scanf("%d %d",&N,&M);
	for(int i=1; i<=N; i++){
		scanf("%d",&a[i]);
		X.pb(a[i]);
	}
	sort(X.begin(),X.end());
	for(int i=1; i<=N; i++){
		a[i] = lower_bound(X.begin(),X.end(),a[i])-X.begin()+1;
	}
	process();
	scanf("%d",&Q);
	for(int i=1; i<=Q; i++){
		int x,y,t,t2;
		char op[3];
		scanf("%s %d",op,&x);
		if(op[0] == 'F'){
			printf("%d\n",ans[x]);
		}else{
			scanf("%d",&y);
			y = N-y+1;
			if(x == M) continue;
			printf("%d\n",y);
			for(int j=1; j<=N; j++){
				if(a[x] < a[j] && a[j] <= y){
					a[j]--;
				}
			}
			a[x] = y;
			process();
		}
	}

	return 0;
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:47:11: warning: unused variable 't' [-Wunused-variable]
   int x,y,t,t2;
           ^
cake.cpp:47:13: warning: unused variable 't2' [-Wunused-variable]
   int x,y,t,t2;
             ^
cake.cpp:35:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&N,&M);
                      ^
cake.cpp:37:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
                    ^
cake.cpp:45:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&Q);
                ^
cake.cpp:49:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s %d",op,&x);
                       ^
cake.cpp:53:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&y);
                  ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 3972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2000 ms 4112 KB Execution timed out
2 Execution timed out 2000 ms 4112 KB Execution timed out
3 Execution timed out 2000 ms 4112 KB Execution timed out
4 Execution timed out 2000 ms 4112 KB Execution timed out
5 Execution timed out 2000 ms 4244 KB Execution timed out
6 Execution timed out 2000 ms 4244 KB Execution timed out
7 Execution timed out 2000 ms 4244 KB Execution timed out
8 Execution timed out 2000 ms 4244 KB Execution timed out
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 4824 KB Output isn't correct
2 Incorrect 123 ms 4824 KB Output isn't correct
3 Incorrect 86 ms 4824 KB Output isn't correct
4 Incorrect 0 ms 3972 KB Output isn't correct
5 Incorrect 246 ms 5592 KB Output isn't correct
6 Incorrect 269 ms 5592 KB Output isn't correct
7 Incorrect 179 ms 5592 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 516 ms 3972 KB Output isn't correct
2 Incorrect 839 ms 4112 KB Output isn't correct
3 Execution timed out 2000 ms 4440 KB Execution timed out
4 Execution timed out 2000 ms 4440 KB Execution timed out
5 Incorrect 996 ms 3972 KB Output isn't correct
6 Execution timed out 2000 ms 4824 KB Execution timed out
7 Execution timed out 2000 ms 4112 KB Execution timed out
8 Execution timed out 2000 ms 4824 KB Execution timed out
9 Execution timed out 2000 ms 5592 KB Execution timed out
10 Execution timed out 2000 ms 3972 KB Execution timed out
11 Execution timed out 2000 ms 4244 KB Execution timed out
12 Execution timed out 2000 ms 5592 KB Execution timed out
13 Execution timed out 2000 ms 5592 KB Execution timed out