Submission #571061

# Submission time Handle Problem Language Result Execution time Memory
571061 2022-06-01T07:40:40 Z kshitij_sodani MP3 Player (CEOI10_mp3player) C++14
0 / 100
1000 ms 2900 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define a first
#define b second
#define pb push_back
#define endl '\n'

int n,m,aa;
int it[100001];
int tt[100001];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>aa;
	for(int i=0;i<n;i++){
		char s;
		cin>>s;
		if(s=='+'){
			it[i]=1;
		}
		else{
			it[i]=-1;
		}
		cin>>tt[i+1];
	}
	vector<int> ss;
	for(int i=0;i<n;i++){
		ss.pb(tt[i+1]);
		ss[ss.size()-1]-=tt[i];
		ss[ss.size()-1]-=1;
	}
	sort(ss.begin(),ss.end());
	ss.pb(ss.back()+1);

	
	reverse(ss.begin(),ss.end());
	/*for(auto j:ss){
		cout<<j<<",";
	}
	cout<<endl;*/
	for(int i=0;i<ss.size();i++){
		pair<int,int> cur={aa,aa};
		int st=1;
		for(int j=n-1;j>=0;j--){
			if(tt[j+1]-tt[j]>ss[i]){
				continue;
			}
			if(it[j]==-1){
				cur.b+=1;
				cur.b=min(cur.b,m);
				cur.a+=1;
				if(cur.a==1){
					cur.a=0;
				}
			}
			else{
				cur.a=max(0,cur.a-1);
				cur.b-=1;
				if(cur.b==m-1){
					cur.b=m;
				}
			}
			if(cur.a>cur.b){
				st=0;
				break;
			}
		}
		if(st==1){

			if(i==0){
				cout<<"infinity"<<endl;
			}
			else{
				cout<<ss[i]<<" "<<cur.b<<endl;
			}

			return 0;
		}


	}





	return 0;
}

Compilation message

mp3player.cpp: In function 'int main()':
mp3player.cpp:43:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for(int i=0;i<ss.size();i++){
      |              ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 964 KB Output is correct
2 Incorrect 839 ms 964 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 968 KB Output is correct
2 Execution timed out 1067 ms 1032 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1108 KB Output is correct
2 Correct 7 ms 1108 KB Output is correct
3 Execution timed out 1083 ms 1372 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1580 KB Output is correct
2 Execution timed out 1078 ms 1624 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 2896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 2900 KB Time limit exceeded
2 Halted 0 ms 0 KB -