# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
551748 | krit3379 | Semiexpress (JOI17_semiexpress) | C++17 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |