| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 282630 | DystoriaX | Long Distance Coach (JOI17_coach) | C++14 | 2061 ms | 14292 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
long long x, t;
int n, m, w;
long long s[200010];
pair<long long, int> v[200010];
long long pos[200010], spos[200010];
long long dp[200010], ans;
long long Get(long long x){
return x - (x % t);
}
int main(){
scanf("%lld%d%d%d%lld", &x, &n, &m, &w, &t);
for(int i = 1; i <= n; i++) scanf("%lld", &s[i]);
for(int i = 1; i <= m; i++) scanf("%lld%d", &v[i].fi, &v[i].se), pos[i] = v[i].fi;
sort(v + 1, v + 1 + m);
sort(pos + 1, pos + 1 + m);
memset(spos, -1, sizeof(spos));
s[n + 1] = x;
for(int i = 1; i <= n + 1; i++){
int id = upper_bound(pos + 1, pos + 1 + m, s[i] % t) - pos;
--id;
if(spos[id] == -1 || spos[id] > s[i]) spos[id] = s[i];
}
for(int i = 0; i <= m; i++)
ans += (x - v[i].fi) / t + 1;
ans *= w;
for(int i = 1; i <= m; i++){
dp[i] = dp[i - 1];
if(spos[i] == -1) continue;
long long cost = 0;
for(int k = i - 1; k >= 0; k--){
cost += -((x - (Get(spos[i]) + v[k + 1].fi)) / t + 1) * w + v[k + 1].se;
dp[i] = min(dp[i], dp[k] + cost);
}
}
printf("%lld\n", ans + dp[m]);
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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
