# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
119122 | HungAnhGoldIBO2020 | Semiexpress (JOI17_semiexpress) | C++14 | 3 ms | 512 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<iostream>
#include<queue>
#define int long long
using namespace std;
const int N=3005;
int ar[N],numm[N];
priority_queue<pair<pair<int,int>,int> > ohyeah;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,i,j,k,l,m,num,a,b,c,t,ans=0;
cin>>n>>m>>num>>a>>b>>c>>t;
for(i=1;i<=m;i++){
cin>>ar[i];
}
ar[m+1]=n+1;
for(i=1;i<=m;i++){
if(b*(ar[i]-1)>t){
break;
}
ans+=min((t-b*(ar[i]-1))/a+1,ar[i+1]-ar[i]);
if(t>=b*(ar[i]-1)+c*((t-b*(ar[i]-1))/a+1)&&i<m){
ohyeah.push({{min((t-b*(ar[i]-1)-c*((t-b*(ar[i]-1))/a+1))/a+1,max(ar[i+1]-(ar[i]+(t-b*(ar[i]-1))/a+1),0ll)),min(ar[i+1],ar[i]+(t-b*(ar[i]-1))/a+1+(t-b*(ar[i]-1)-c*((t-b*(ar[i]-1))/a+1))/a+1)},i});
//cout<<min((t-b*(ar[i]-1)-c*((t-b*(ar[i]-1))/a+1))/a+1,max(ar[i+1]-(ar[i]+(t-b*(ar[i]-1))/a+1),0ll))<<" "<<min(ar[i+1],ar[i]+(t-b*(ar[i]-1))/a+1+(t-b*(ar[i]-1)-c*((t-b*(ar[i]-1))/a+1))/a+1)<<" cac"<<endl;
}
}
//cout<<ans<<endl;
for(i=1;i<=num-m;i++){
if(ohyeah.size()){
ans+=ohyeah.top().first.first;
j=ohyeah.top().first.second;
k=ohyeah.top().second;
l=ohyeah.top().first.first;
ohyeah.pop();
if(t>=b*(ar[k]-1)+c*(j-ar[k])){
ohyeah.push({{min((t-b*(ar[k]-1)-c*(j-ar[k]))/a+1,ar[k+1]-j),min(ar[k+1],j+(t-b*(ar[k]-1)-c*(j-ar[k]))/a+1)},k});
//if(i<=10){
// cout<<min((t-b*(ar[k]-1)+c*(j-ar[k]))/a+1,ar[k+1]-j)<<" "<<min(ar[k+1],j+(t-b*(ar[k]-1)+c*(j-ar[k]))/a+1)<<endl;
//}
}
}
else{
break;
}
}
cout<<ans-1;
}
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... |