# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
198575 | 2020-01-26T16:47:48 Z | arnold518 | Long Distance Coach (JOI17_coach) | C++14 | 2000 ms | 21240 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5; struct Data { ll D, C; bool operator < (const Data &p) { return D<p.D; } }; int N, M; ll X, W, T, S[MAXN+10], dp[MAXN+10]; Data A[MAXN+10]; vector<pll> V[MAXN+10]; int main() { int i, j; scanf("%lld%d%d%lld%lld", &X, &N, &M, &W, &T); for(i=1; i<=N; i++) scanf("%lld", &S[i]); S[N+1]=X; for(i=1; i<=M; i++) scanf("%lld%lld", &A[i].D, &A[i].C); sort(A+1, A+M+1); sort(S+1, S+N+1); for(i=1; i<=N+1; i++) { ll l, r; if(S[i-1]/T==S[i]/T) { l=S[i-1]%T, r=S[i]%T; l=lower_bound(A+1, A+M+1, (Data){l, 0})-A; r=lower_bound(A+1, A+M+1, (Data){r, 0})-A-1; } else { l=0, r=S[i]%T; l=lower_bound(A+1, A+M+1, (Data){l, 0})-A; r=lower_bound(A+1, A+M+1, (Data){r, 0})-A-1; } if(l<=r) V[r].push_back({l, S[i]/T}); } dp[0]=(X/T+1)*W; for(i=1; i<=M; i++) { if(A[i].D<=X%T) dp[i]=dp[i-1]+(X/T+1)*W; else dp[i]=dp[i-1]+X/T*W; for(auto it : V[i]) { ll s=0; for(j=i; j>=it.first; j--) { s+=A[j].C+W*it.second; dp[i]=min(dp[i], dp[j-1]+s); } } } printf("%lld", dp[M]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5112 KB | Output is correct |
3 | Correct | 8 ms | 4984 KB | Output is correct |
4 | Correct | 8 ms | 4984 KB | Output is correct |
5 | Correct | 8 ms | 5112 KB | Output is correct |
6 | Correct | 8 ms | 4984 KB | Output is correct |
7 | Correct | 8 ms | 4984 KB | Output is correct |
8 | Correct | 8 ms | 5112 KB | Output is correct |
9 | Correct | 8 ms | 4984 KB | Output is correct |
10 | Correct | 8 ms | 5112 KB | Output is correct |
11 | Correct | 8 ms | 5112 KB | Output is correct |
12 | Correct | 8 ms | 4988 KB | Output is correct |
13 | Correct | 8 ms | 4984 KB | Output is correct |
14 | Correct | 8 ms | 4984 KB | Output is correct |
15 | Correct | 8 ms | 4984 KB | Output is correct |
16 | Correct | 7 ms | 4984 KB | Output is correct |
17 | Correct | 8 ms | 4984 KB | Output is correct |
18 | Correct | 8 ms | 5112 KB | Output is correct |
19 | Correct | 8 ms | 4984 KB | Output is correct |
20 | Correct | 8 ms | 4984 KB | Output is correct |
21 | Correct | 9 ms | 4984 KB | Output is correct |
22 | Correct | 8 ms | 4984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5112 KB | Output is correct |
3 | Correct | 8 ms | 4984 KB | Output is correct |
4 | Correct | 8 ms | 4984 KB | Output is correct |
5 | Correct | 8 ms | 5112 KB | Output is correct |
6 | Correct | 8 ms | 4984 KB | Output is correct |
7 | Correct | 8 ms | 4984 KB | Output is correct |
8 | Correct | 8 ms | 5112 KB | Output is correct |
9 | Correct | 8 ms | 4984 KB | Output is correct |
10 | Correct | 8 ms | 5112 KB | Output is correct |
11 | Correct | 8 ms | 5112 KB | Output is correct |
12 | Correct | 8 ms | 4988 KB | Output is correct |
13 | Correct | 8 ms | 4984 KB | Output is correct |
14 | Correct | 8 ms | 4984 KB | Output is correct |
15 | Correct | 8 ms | 4984 KB | Output is correct |
16 | Correct | 7 ms | 4984 KB | Output is correct |
17 | Correct | 8 ms | 4984 KB | Output is correct |
18 | Correct | 8 ms | 5112 KB | Output is correct |
19 | Correct | 8 ms | 4984 KB | Output is correct |
20 | Correct | 8 ms | 4984 KB | Output is correct |
21 | Correct | 9 ms | 4984 KB | Output is correct |
22 | Correct | 8 ms | 4984 KB | Output is correct |
23 | Correct | 8 ms | 5112 KB | Output is correct |
24 | Correct | 9 ms | 4984 KB | Output is correct |
25 | Correct | 8 ms | 4984 KB | Output is correct |
26 | Correct | 8 ms | 4984 KB | Output is correct |
27 | Correct | 8 ms | 4984 KB | Output is correct |
28 | Correct | 8 ms | 4984 KB | Output is correct |
29 | Correct | 8 ms | 4984 KB | Output is correct |
30 | Correct | 8 ms | 5112 KB | Output is correct |
31 | Correct | 9 ms | 5112 KB | Output is correct |
32 | Correct | 8 ms | 4984 KB | Output is correct |
33 | Correct | 8 ms | 4984 KB | Output is correct |
34 | Correct | 8 ms | 5112 KB | Output is correct |
35 | Correct | 9 ms | 5112 KB | Output is correct |
36 | Correct | 8 ms | 5112 KB | Output is correct |
37 | Correct | 8 ms | 4984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5112 KB | Output is correct |
3 | Correct | 8 ms | 4984 KB | Output is correct |
4 | Correct | 8 ms | 4984 KB | Output is correct |
5 | Correct | 8 ms | 5112 KB | Output is correct |
6 | Correct | 8 ms | 4984 KB | Output is correct |
7 | Correct | 8 ms | 4984 KB | Output is correct |
8 | Correct | 8 ms | 5112 KB | Output is correct |
9 | Correct | 8 ms | 4984 KB | Output is correct |
10 | Correct | 8 ms | 5112 KB | Output is correct |
11 | Correct | 8 ms | 5112 KB | Output is correct |
12 | Correct | 8 ms | 4988 KB | Output is correct |
13 | Correct | 8 ms | 4984 KB | Output is correct |
14 | Correct | 8 ms | 4984 KB | Output is correct |
15 | Correct | 8 ms | 4984 KB | Output is correct |
16 | Correct | 7 ms | 4984 KB | Output is correct |
17 | Correct | 8 ms | 4984 KB | Output is correct |
18 | Correct | 8 ms | 5112 KB | Output is correct |
19 | Correct | 8 ms | 4984 KB | Output is correct |
20 | Correct | 8 ms | 4984 KB | Output is correct |
21 | Correct | 9 ms | 4984 KB | Output is correct |
22 | Correct | 8 ms | 4984 KB | Output is correct |
23 | Correct | 8 ms | 5112 KB | Output is correct |
24 | Correct | 9 ms | 4984 KB | Output is correct |
25 | Correct | 8 ms | 4984 KB | Output is correct |
26 | Correct | 8 ms | 4984 KB | Output is correct |
27 | Correct | 8 ms | 4984 KB | Output is correct |
28 | Correct | 8 ms | 4984 KB | Output is correct |
29 | Correct | 8 ms | 4984 KB | Output is correct |
30 | Correct | 8 ms | 5112 KB | Output is correct |
31 | Correct | 9 ms | 5112 KB | Output is correct |
32 | Correct | 8 ms | 4984 KB | Output is correct |
33 | Correct | 8 ms | 4984 KB | Output is correct |
34 | Correct | 8 ms | 5112 KB | Output is correct |
35 | Correct | 9 ms | 5112 KB | Output is correct |
36 | Correct | 8 ms | 5112 KB | Output is correct |
37 | Correct | 8 ms | 4984 KB | Output is correct |
38 | Correct | 12 ms | 5112 KB | Output is correct |
39 | Correct | 12 ms | 5240 KB | Output is correct |
40 | Correct | 13 ms | 5244 KB | Output is correct |
41 | Correct | 13 ms | 5112 KB | Output is correct |
42 | Correct | 13 ms | 5244 KB | Output is correct |
43 | Correct | 12 ms | 5240 KB | Output is correct |
44 | Correct | 13 ms | 5240 KB | Output is correct |
45 | Correct | 12 ms | 5112 KB | Output is correct |
46 | Correct | 13 ms | 5240 KB | Output is correct |
47 | Correct | 12 ms | 5240 KB | Output is correct |
48 | Correct | 12 ms | 5240 KB | Output is correct |
49 | Correct | 10 ms | 5112 KB | Output is correct |
50 | Correct | 12 ms | 5112 KB | Output is correct |
51 | Correct | 12 ms | 5240 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 4984 KB | Output is correct |
2 | Correct | 7 ms | 5112 KB | Output is correct |
3 | Correct | 8 ms | 4984 KB | Output is correct |
4 | Correct | 8 ms | 4984 KB | Output is correct |
5 | Correct | 8 ms | 5112 KB | Output is correct |
6 | Correct | 8 ms | 4984 KB | Output is correct |
7 | Correct | 8 ms | 4984 KB | Output is correct |
8 | Correct | 8 ms | 5112 KB | Output is correct |
9 | Correct | 8 ms | 4984 KB | Output is correct |
10 | Correct | 8 ms | 5112 KB | Output is correct |
11 | Correct | 8 ms | 5112 KB | Output is correct |
12 | Correct | 8 ms | 4988 KB | Output is correct |
13 | Correct | 8 ms | 4984 KB | Output is correct |
14 | Correct | 8 ms | 4984 KB | Output is correct |
15 | Correct | 8 ms | 4984 KB | Output is correct |
16 | Correct | 7 ms | 4984 KB | Output is correct |
17 | Correct | 8 ms | 4984 KB | Output is correct |
18 | Correct | 8 ms | 5112 KB | Output is correct |
19 | Correct | 8 ms | 4984 KB | Output is correct |
20 | Correct | 8 ms | 4984 KB | Output is correct |
21 | Correct | 9 ms | 4984 KB | Output is correct |
22 | Correct | 8 ms | 4984 KB | Output is correct |
23 | Correct | 8 ms | 5112 KB | Output is correct |
24 | Correct | 9 ms | 4984 KB | Output is correct |
25 | Correct | 8 ms | 4984 KB | Output is correct |
26 | Correct | 8 ms | 4984 KB | Output is correct |
27 | Correct | 8 ms | 4984 KB | Output is correct |
28 | Correct | 8 ms | 4984 KB | Output is correct |
29 | Correct | 8 ms | 4984 KB | Output is correct |
30 | Correct | 8 ms | 5112 KB | Output is correct |
31 | Correct | 9 ms | 5112 KB | Output is correct |
32 | Correct | 8 ms | 4984 KB | Output is correct |
33 | Correct | 8 ms | 4984 KB | Output is correct |
34 | Correct | 8 ms | 5112 KB | Output is correct |
35 | Correct | 9 ms | 5112 KB | Output is correct |
36 | Correct | 8 ms | 5112 KB | Output is correct |
37 | Correct | 8 ms | 4984 KB | Output is correct |
38 | Correct | 12 ms | 5112 KB | Output is correct |
39 | Correct | 12 ms | 5240 KB | Output is correct |
40 | Correct | 13 ms | 5244 KB | Output is correct |
41 | Correct | 13 ms | 5112 KB | Output is correct |
42 | Correct | 13 ms | 5244 KB | Output is correct |
43 | Correct | 12 ms | 5240 KB | Output is correct |
44 | Correct | 13 ms | 5240 KB | Output is correct |
45 | Correct | 12 ms | 5112 KB | Output is correct |
46 | Correct | 13 ms | 5240 KB | Output is correct |
47 | Correct | 12 ms | 5240 KB | Output is correct |
48 | Correct | 12 ms | 5240 KB | Output is correct |
49 | Correct | 10 ms | 5112 KB | Output is correct |
50 | Correct | 12 ms | 5112 KB | Output is correct |
51 | Correct | 12 ms | 5240 KB | Output is correct |
52 | Execution timed out | 2087 ms | 21240 KB | Time limit exceeded |
53 | Halted | 0 ms | 0 KB | - |