Submission #135471

# Submission time Handle Problem Language Result Execution time Memory
135471 2019-07-24T06:10:52 Z 송준혁(#3252) MP3 Player (CEOI10_mp3player) C++14
30 / 100
36 ms 864 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;
	}
	
	LL L=0, R=INF;
	while (L <= R){
		LL mid = (L + R) / 2;
		int l=T, r=T;
		for (int i=N-1; i>0; i--){
			if (d[i] > mid) 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) R = mid - 1;
		else L = mid + 1, ans = mid, 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;
          ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 504 KB Output is correct
2 Correct 16 ms 504 KB Output is correct
3 Correct 12 ms 504 KB Output is correct
4 Correct 10 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 504 KB Output is correct
2 Correct 16 ms 504 KB Output is correct
3 Incorrect 12 ms 504 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 864 KB Output isn't correct
2 Halted 0 ms 0 KB -