# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
319479 | 2020-11-05T11:05:35 Z | arnold518 | Long Distance Coach (JOI17_coach) | C++14 | 2000 ms | 39252 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 = 4e5; ll X, W, T; int N, M, K; vector<pll> V; ll S[MAXN+10]; pll C[MAXN+10]; ll A[MAXN+10]; ll dp[MAXN+10]; map<ll, ll> MM; int main() { scanf("%lld%d%d%lld%lld", &X, &N, &M, &W, &T); for(int i=1; i<=N; i++) scanf("%lld", &S[i]); sort(S+1, S+N+1, greater<ll>()); { ll x, y; x=X%T; y=X/T; MM[x]=-y; } for(int i=1; i<=N; i++) { ll x, y; x=S[i]%T; y=S[i]/T; MM[x]=-y; } for(int i=1; i<=M; i++) { scanf("%lld%lld", &C[i].first, &C[i].second); dp[0]+=C[i].second; MM[C[i].first]=C[i].second; dp[0]+=W*(X/T); if(C[i].first<=X%T) dp[0]+=W; } dp[0]+=W*(X/T+1); K=MM.size(); int t=1, P; for(auto it : MM) { if(it.first==X%T) P=t; A[t++]=it.second; } for(int i=1; i<=K; i++) { if(A[i]>0) { dp[i]=dp[i-1]-A[i]; } else { dp[i]=1e18; ll t=0; for(int j=i; j>=1; j--) { if(A[j]>0) { t+=X/T+A[i]; if(j<=P) t++; } dp[i]=min(dp[i], dp[j-1]-t*W); } } } printf("%lld\n", dp[K]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 364 KB | Output is correct |
32 | Correct | 1 ms | 364 KB | Output is correct |
33 | Correct | 1 ms | 396 KB | Output is correct |
34 | Correct | 1 ms | 396 KB | Output is correct |
35 | Correct | 1 ms | 364 KB | Output is correct |
36 | Correct | 1 ms | 364 KB | Output is correct |
37 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 364 KB | Output is correct |
32 | Correct | 1 ms | 364 KB | Output is correct |
33 | Correct | 1 ms | 396 KB | Output is correct |
34 | Correct | 1 ms | 396 KB | Output is correct |
35 | Correct | 1 ms | 364 KB | Output is correct |
36 | Correct | 1 ms | 364 KB | Output is correct |
37 | Correct | 1 ms | 364 KB | Output is correct |
38 | Correct | 13 ms | 876 KB | Output is correct |
39 | Correct | 9 ms | 876 KB | Output is correct |
40 | Correct | 9 ms | 876 KB | Output is correct |
41 | Correct | 13 ms | 748 KB | Output is correct |
42 | Correct | 13 ms | 748 KB | Output is correct |
43 | Correct | 9 ms | 748 KB | Output is correct |
44 | Correct | 13 ms | 748 KB | Output is correct |
45 | Correct | 13 ms | 748 KB | Output is correct |
46 | Correct | 8 ms | 748 KB | Output is correct |
47 | Correct | 9 ms | 748 KB | Output is correct |
48 | Correct | 17 ms | 748 KB | Output is correct |
49 | Correct | 13 ms | 748 KB | Output is correct |
50 | Correct | 13 ms | 748 KB | Output is correct |
51 | Correct | 13 ms | 748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 364 KB | Output is correct |
32 | Correct | 1 ms | 364 KB | Output is correct |
33 | Correct | 1 ms | 396 KB | Output is correct |
34 | Correct | 1 ms | 396 KB | Output is correct |
35 | Correct | 1 ms | 364 KB | Output is correct |
36 | Correct | 1 ms | 364 KB | Output is correct |
37 | Correct | 1 ms | 364 KB | Output is correct |
38 | Correct | 13 ms | 876 KB | Output is correct |
39 | Correct | 9 ms | 876 KB | Output is correct |
40 | Correct | 9 ms | 876 KB | Output is correct |
41 | Correct | 13 ms | 748 KB | Output is correct |
42 | Correct | 13 ms | 748 KB | Output is correct |
43 | Correct | 9 ms | 748 KB | Output is correct |
44 | Correct | 13 ms | 748 KB | Output is correct |
45 | Correct | 13 ms | 748 KB | Output is correct |
46 | Correct | 8 ms | 748 KB | Output is correct |
47 | Correct | 9 ms | 748 KB | Output is correct |
48 | Correct | 17 ms | 748 KB | Output is correct |
49 | Correct | 13 ms | 748 KB | Output is correct |
50 | Correct | 13 ms | 748 KB | Output is correct |
51 | Correct | 13 ms | 748 KB | Output is correct |
52 | Execution timed out | 2062 ms | 39252 KB | Time limit exceeded |
53 | Halted | 0 ms | 0 KB | - |