답안 #164454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164454 2019-11-20T17:14:10 Z Lawliet 케이크 (CEOI14_cake) C++14
35 / 100
2000 ms 3972 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 250010;
const int INF = 1000000010;

int n, p, q;

int v[MAXN];
int ans[MAXN];

void rebuild()
{
	int L = p - 1;
	int R = p + 1;
	int curTime = 0;

	ans[ p ] = curTime++;

	while( L != 0 || R != n + 1 )
	{
		if( v[ L ] < v[ R ] ) ans[ L-- ] = curTime++;
		else ans[ R++ ] = curTime++;
	}
}

int main()
{
	scanf("%d %d",&n,&p);

	v[ 0 ] = v[ n + 1 ] = INF;

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	rebuild();

	scanf("%d",&q);

	for(int i = 1 ; i <= q ; i++)
	{
		char a;
		int pos;
		scanf(" %c %d",&a,&pos);

		if( a == 'F' ) printf("%d\n",ans[ pos ]);
		if( a == 'E' )
		{
			int newD;
			scanf("%d",&newD);

			for(int j = 1 ; j <= n ; j++)
				if( v[pos] < v[j] && v[j] <= n - newD + 1 ) v[j]--;

			v[ pos ] = n - newD + 1;
			
			rebuild();
		}
	}
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&p);
  ~~~~~^~~~~~~~~~~~~~~
cake.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&v[i]);
   ~~~~~^~~~~~~~~~~~
cake.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ~~~~~^~~~~~~~~
cake.cpp:45:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c %d",&a,&pos);
   ~~~~~^~~~~~~~~~~~~~~~~~
cake.cpp:51:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&newD);
    ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 17 ms 376 KB Output is correct
5 Correct 273 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2045 ms 1192 KB Time limit exceeded
2 Execution timed out 2066 ms 1400 KB Time limit exceeded
3 Execution timed out 2058 ms 1272 KB Time limit exceeded
4 Execution timed out 2065 ms 1144 KB Time limit exceeded
5 Execution timed out 2045 ms 1064 KB Time limit exceeded
6 Execution timed out 2054 ms 1148 KB Time limit exceeded
7 Execution timed out 2058 ms 1116 KB Time limit exceeded
8 Execution timed out 2049 ms 1060 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 2428 KB Output is correct
2 Correct 64 ms 2424 KB Output is correct
3 Correct 63 ms 2296 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 163 ms 3684 KB Output is correct
6 Correct 151 ms 3972 KB Output is correct
7 Correct 106 ms 3568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 1064 KB Output is correct
2 Correct 705 ms 1192 KB Output is correct
3 Execution timed out 2061 ms 1528 KB Time limit exceeded
4 Execution timed out 2058 ms 1708 KB Time limit exceeded
5 Correct 848 ms 1560 KB Output is correct
6 Execution timed out 2058 ms 1780 KB Time limit exceeded
7 Execution timed out 2064 ms 1508 KB Time limit exceeded
8 Execution timed out 2057 ms 1784 KB Time limit exceeded
9 Execution timed out 2059 ms 2936 KB Time limit exceeded
10 Execution timed out 2062 ms 1868 KB Time limit exceeded
11 Execution timed out 2054 ms 1296 KB Time limit exceeded
12 Execution timed out 2060 ms 2424 KB Time limit exceeded
13 Execution timed out 2041 ms 2672 KB Time limit exceeded