Submission #449898

# Submission time Handle Problem Language Result Execution time Memory
449898 2021-08-02T09:20:07 Z vanic Cake (CEOI14_cake) C++14
15 / 100
2000 ms 1712 KB
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

const int maxn=1e4+5;

int a[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, x;
	cin >> n >> x;
	x--;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	int q;
	cin >> q;
	char c;
	int e, f;
	int pos, br;
	int l, d;
	for(int i=0; i<q; i++){
		cin >> c >> e;
		e--;
		if(c=='F'){
			pos=x;
			br=0;
			l=pos-1;
			d=pos+1;
			while(pos!=e){
				br++;
				if(l==-1 || (d<n && a[l]>a[d])){
					pos=d;
					d++;
				}
				else{
					pos=l;
					l--;
				}
			}
			cout << br << '\n';
		}
		else{
			cin >> f;
			f--;
			f=n-f;
			if(f>a[e]){
				for(int j=0; j<n; j++){
					if(a[j]>a[e] && a[j]<=f){
						a[j]--;
					}
				}
				a[e]=f;
			}
			else if(f<a[e]){
				for(int j=0; j<n; j++){
					if(a[j]>=f && a[j]<a[e]){
						a[j]++;
					}
					a[e]=f;
				}
			}
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 13 ms 372 KB Output is correct
5 Correct 233 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 656 KB Time limit exceeded
2 Execution timed out 2095 ms 704 KB Time limit exceeded
3 Execution timed out 2090 ms 652 KB Time limit exceeded
4 Execution timed out 2079 ms 652 KB Time limit exceeded
5 Runtime error 3 ms 716 KB Execution killed with signal 11
6 Runtime error 2 ms 588 KB Execution killed with signal 11
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Runtime error 2 ms 588 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 588 KB Execution killed with signal 11
2 Runtime error 3 ms 588 KB Execution killed with signal 11
3 Runtime error 3 ms 588 KB Execution killed with signal 11
4 Correct 1 ms 312 KB Output is correct
5 Runtime error 2 ms 716 KB Execution killed with signal 11
6 Runtime error 2 ms 712 KB Execution killed with signal 11
7 Runtime error 2 ms 716 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 340 ms 752 KB Output is correct
2 Correct 565 ms 796 KB Output is correct
3 Runtime error 2 ms 588 KB Execution killed with signal 11
4 Runtime error 2 ms 716 KB Execution killed with signal 11
5 Correct 685 ms 1020 KB Output is correct
6 Runtime error 2 ms 716 KB Execution killed with signal 11
7 Execution timed out 2093 ms 1096 KB Time limit exceeded
8 Runtime error 2 ms 716 KB Execution killed with signal 11
9 Runtime error 2 ms 588 KB Execution killed with signal 11
10 Execution timed out 2095 ms 1712 KB Time limit exceeded
11 Runtime error 2 ms 716 KB Execution killed with signal 11
12 Runtime error 2 ms 576 KB Execution killed with signal 11
13 Runtime error 2 ms 716 KB Execution killed with signal 11