Submission #571063

#TimeUsernameProblemLanguageResultExecution timeMemory
571063kshitij_sodaniMP3 Player (CEOI10_mp3player)C++14
50 / 100
1091 ms1876 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...