Submission #346847

# Submission time Handle Problem Language Result Execution time Memory
346847 2021-01-11T08:57:24 Z arnold518 MP3 Player (CEOI10_mp3player) C++14
60 / 100
1000 ms 1516 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N, Vmax, V2;
pii A[MAXN+10];
int B[MAXN+10];

int main()
{
	scanf("%d%d%d", &N, &Vmax, &V2); N--;
	int t;
	scanf(" %*c%d", &t);
	for(int i=1; i<=N; i++)
	{
		int p; char q;
		scanf(" %c%d", &q, &p);
		if(q=='+') A[i]={p-t, i};
		else A[i]={p-t, -i};
		t=p;
	}
	sort(A+1, A+N+1);

	int ans1=A[1].first-1, ans2=V2;
	A[N+1].first=2147483647;
	for(int i=1; i<=N; i++)
	{
		if(A[i].second>0) B[A[i].second]=1;
		else B[-A[i].second]=-1;
		if(A[i].first==A[i+1].first) continue;

		int l=V2, r=V2;
		bool flag=true;
		for(int j=N; j>=1; j--)
		{
			if(B[j]==0) continue;
			if(l!=0) l-=B[j];
			if(r!=Vmax) r-=B[j];
			if(l>r)
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			ans1=A[i+1].first-1;
			ans2=r;
		}
	}
	if(ans1==2147483646) printf("infinity\n");
	else printf("%d %d\n", ans1, ans2);
}

Compilation message

mp3player.cpp: In function 'int main()':
mp3player.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%d%d%d", &N, &Vmax, &V2); N--;
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
mp3player.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf(" %*c%d", &t);
      |  ~~~~~^~~~~~~~~~~~~~
mp3player.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   scanf(" %c%d", &q, &p);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 15 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 364 KB Output is correct
2 Correct 20 ms 364 KB Output is correct
3 Correct 20 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 620 KB Output is correct
2 Correct 565 ms 752 KB Output is correct
3 Correct 569 ms 636 KB Output is correct
4 Correct 471 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 620 KB Output is correct
2 Correct 726 ms 620 KB Output is correct
3 Correct 757 ms 1276 KB Output is correct
4 Correct 525 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 229 ms 620 KB Output is correct
2 Correct 481 ms 748 KB Output is correct
3 Execution timed out 1080 ms 1516 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 1516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 1516 KB Time limit exceeded
2 Halted 0 ms 0 KB -