# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551748 | krit3379 | Semiexpress (JOI17_semiexpress) | C++17 | 1 ms | 340 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;
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |