# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
571063 | kshitij_sodani | MP3 Player (CEOI10_mp3player) | C++14 | 1091 ms | 1876 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |