답안 #135474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
135474 2019-07-24T06:17:26 Z 송준혁(#3252) MP3 Player (CEOI10_mp3player) C++14
30 / 100
1000 ms 760 KB
#include <bits/stdc++.h>
#define INF 1234567890
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, V, T;
int ans, V1;
char ch[101010];
int d[101010];

int main(){
	scanf("%d %d %d", &N, &V, &T);
	int x, y;
	for (int i=0; i<N; i++){
		scanf(" %c %d", &ch[i], &y);
		d[i] = y - x, x = y;
	}
	d[N] = INF+1;
	for (int j=1; j<=N; j++){
		int l=T, r=T;
		for (int i=N-1; i>0; i--){
			if (d[i] > d[j]-1) continue;
			if (ch[i] == '+'){
				l--;
				if (r != V) r--; 
			}
			else{
				r++;
				if (l != 0) l++;
			}
			if (l > V || r < 0) break;
			r = min(r, V);
			l = max(l, 0);
		} 
		if (l <= V && r >= 0 && ans < d[j]-1) ans = d[j]-1, V1 = r;
	}

	if (ans == INF) puts("infinity");
	else printf("%d %d\n", ans, V1);
	return 0;
}
/*
6 3 3
- 0
+ 4
+ 6
- 8
- 9
+ 12
*/

Compilation message

mp3player.cpp: In function 'int main()':
mp3player.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &N, &V, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mp3player.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c %d", &ch[i], &y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
mp3player.cpp:17:12: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   d[i] = y - x, x = y;
          ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 376 KB Output is correct
2 Correct 38 ms 376 KB Output is correct
3 Correct 18 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 14 ms 376 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 384 KB Output is correct
2 Correct 27 ms 376 KB Output is correct
3 Incorrect 23 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 376 KB Output is correct
2 Execution timed out 1083 ms 376 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 504 KB Output is correct
2 Execution timed out 1080 ms 504 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 490 ms 504 KB Output is correct
2 Execution timed out 1078 ms 504 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1075 ms 504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1038 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 760 KB Time limit exceeded
2 Halted 0 ms 0 KB -