Submission #119122

#TimeUsernameProblemLanguageResultExecution timeMemory
119122HungAnhGoldIBO2020Semiexpress (JOI17_semiexpress)C++14
100 / 100
3 ms512 KiB
#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)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:11:14: warning: variable 'l' set but not used [-Wunused-but-set-variable]
  int n,i,j,k,l,m,num,a,b,c,t,ans=0;
              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...