Submission #571063

# Submission time Handle Problem Language Result Execution time Memory
571063 2022-06-01T07:46:59 Z kshitij_sodani MP3 Player (CEOI10_mp3player) C++14
50 / 100
1000 ms 1876 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=1;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());
	vector<int> ee;
	for(auto j:ss){
		if(ee.size()==0){
			ee.pb(j);
			continue;
		}
		if(ee.back()==j){

		}
		else{
			ee.pb(j);
		}
	}
	ss=ee;
	/*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>=1;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:57:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i=0;i<ss.size();i++){
      |              ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 17 ms 408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 340 KB Output is correct
2 Correct 23 ms 388 KB Output is correct
3 Correct 19 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 596 KB Output is correct
2 Correct 868 ms 720 KB Output is correct
3 Correct 499 ms 724 KB Output is correct
4 Correct 630 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 724 KB Output is correct
2 Execution timed out 1083 ms 784 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 852 KB Output is correct
2 Correct 7 ms 852 KB Output is correct
3 Execution timed out 1091 ms 1112 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1112 KB Output is correct
2 Execution timed out 1091 ms 1240 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 1752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 1876 KB Time limit exceeded
2 Halted 0 ms 0 KB -