Submission #551748

#TimeUsernameProblemLanguageResultExecution timeMemory
551748krit3379Semiexpress (JOI17_semiexpress)C++17
100 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define N 3005 long long n,a,b,c,t,x[N],v[N],now,nxt,ans=-1; priority_queue<pair<long long,long long>> q; int main(){ int m,k,i,j; scanf("%lld %d %d %lld %lld %lld %lld",&n,&m,&k,&a,&b,&c,&t); for(i=1;i<=m;i++)scanf("%lld",&x[i]); x[m+1]=n+1; k-=m; for(i=1;i<=m;i++){ now=b*(x[i]-1);//time spent if(now>t)break; nxt=x[i]+(t-now)/a;//move with a->train til we cannot nxt=min(nxt,x[i+1]-1); ans+=nxt-x[i]+1; v[i]=nxt+1; } for(i=1;i<=m;i++){ if(v[i]>=x[i+1]||!v[i])continue; now=b*(x[i]-1)+c*(v[i]-x[i]); if(now>t)continue; nxt=v[i]+(t-now)/a; nxt=min(nxt,x[i+1]-1); q.push({nxt-v[i]+1,i}); v[i]=nxt+1; } while(k--&&!q.empty()){ auto [val,i]=q.top(); q.pop(); ans+=val; if(v[i]>=x[i+1]||!v[i])continue; now=b*(x[i]-1)+c*(v[i]-x[i]); if(now>t)continue; nxt=v[i]+(t-now)/a; nxt=min(nxt,x[i+1]-1); q.push({nxt-v[i]+1,i}); v[i]=nxt+1; } printf("%lld",ans); return 0; }

Compilation message (stderr)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:9:15: warning: unused variable 'j' [-Wunused-variable]
    9 |     int m,k,i,j;
      |               ^
semiexpress.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld %d %d %lld %lld %lld %lld",&n,&m,&k,&a,&b,&c,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(i=1;i<=m;i++)scanf("%lld",&x[i]);
      |                      ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...