Submission #57914

# Submission time Handle Problem Language Result Execution time Memory
57914 2018-07-16T13:52:43 Z MatheusLealV Cake (CEOI14_cake) C++17
35 / 100
2000 ms 3752 KB
#include <bits/stdc++.h>
#define N 250050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;

int n, a, v[N], ans[N], q;

inline void process()
{
	int st = a, en = a, cnt = 1;

	ans[a] = 0;

	while(st > 1 or en < n)
	{
		//cout<<st<<" "<<en<<'\n';

		if( (v[st - 1] > v[en + 1] and en < n) or st <= 1)
		{
			ans[en + 1] = cnt;

			en ++;
		}

		else ans[st - 1] = cnt, st --;

		cnt ++;
	}

	//for(int i = 1; i <= n; i++) cout<<ans[i]<<" \n"[i == n];
}

void update(int id, int e)
{
	vector<pii> val;

	int pos;

	for(int i = 1; i <= n; i++) if(i == id) pos = i;

	for(int i = 1; i <= n; i++)
	{
		if(i == id) continue;

		if(v[i] <= (n - e + 1) and v[i] > v[id]) v[i] --;
	}

	v[id] = (n - e + 1); 

	process();
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);

	cin>>n>>a;

	for(int i = 1; i <= n; i++) cin>>v[i];

	process();

	cin>>q;

	for(int i = 1; i <= q; i++)
	{
		char c; int a, b;

		cin>>c>>a;

		if(c == 'F') cout<<ans[a]<<'\n';

		else
		{
			cin>>b;

			update(a, b);
		}
	}
}

Compilation message

cake.cpp: In function 'void update(int, int)':
cake.cpp:39:6: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
  int pos;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 448 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 18 ms 468 KB Output is correct
5 Correct 292 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2057 ms 860 KB Time limit exceeded
2 Execution timed out 2074 ms 1096 KB Time limit exceeded
3 Execution timed out 2057 ms 1096 KB Time limit exceeded
4 Execution timed out 2069 ms 1096 KB Time limit exceeded
5 Execution timed out 2074 ms 1200 KB Time limit exceeded
6 Execution timed out 2063 ms 1200 KB Time limit exceeded
7 Execution timed out 2088 ms 1200 KB Time limit exceeded
8 Execution timed out 2062 ms 1200 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 93 ms 2324 KB Output is correct
2 Correct 56 ms 2324 KB Output is correct
3 Correct 51 ms 2324 KB Output is correct
4 Correct 2 ms 2324 KB Output is correct
5 Correct 202 ms 3752 KB Output is correct
6 Correct 173 ms 3752 KB Output is correct
7 Correct 112 ms 3752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 513 ms 3752 KB Output is correct
2 Correct 763 ms 3752 KB Output is correct
3 Execution timed out 2067 ms 3752 KB Time limit exceeded
4 Execution timed out 2058 ms 3752 KB Time limit exceeded
5 Correct 1033 ms 3752 KB Output is correct
6 Execution timed out 2076 ms 3752 KB Time limit exceeded
7 Execution timed out 2087 ms 3752 KB Time limit exceeded
8 Execution timed out 2071 ms 3752 KB Time limit exceeded
9 Execution timed out 2081 ms 3752 KB Time limit exceeded
10 Execution timed out 2073 ms 3752 KB Time limit exceeded
11 Execution timed out 2071 ms 3752 KB Time limit exceeded
12 Execution timed out 2079 ms 3752 KB Time limit exceeded
13 Execution timed out 2072 ms 3752 KB Time limit exceeded