# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
127893 | 2019-07-10T08:14:49 Z | 송준혁(#3112) | Long Distance Coach (JOI17_coach) | C++14 | 2000 ms | 1968 KB |
#include <bits/stdc++.h> #define INF (1ll<<62) using namespace std; typedef long long LL; typedef pair<LL, LL> pii; LL X, W, T; int N, M; LL P[3030], ans; pii A[3030]; LL D[3030][3030]; LL C[3030][3030]; int main(){ scanf("%lld %d %d %lld %lld", &X, &M, &N, &W, &T); for (int i=1; i<=M; i++) scanf("%lld", &P[i]); M++; P[M] = X; sort(P+1, P+M+1); for (int i=1; i<=N; i++) scanf("%lld %lld", &A[i].first, &A[i].second); sort(A+1, A+N+1, greater<pii>()); for (int i=1; i<=N; i++) { for (int j=1; j<i; j++){ LL Min = INF; for (int k=1; k<=M; k++) if (A[i].first < P[k]%T && P[k]%T <= A[j].first) Min = min(Min, P[k]); if (Min == INF) C[i][j] = -INF; else{ C[i][j] = W * (((X-A[i].first+T-1)/T) - ((Min-A[i].first+T-1)/T) + 1) - A[i].second; for (int k=1; k<=M; k++) if (P[k] > Min && P[k]%T == A[i].first) C[i][j] -= W; } } LL Min = INF; for (int k=1; k<=M; k++) if (A[i].first < P[k]%T || P[k]%T == 0) Min = min(Min, P[k]); if (Min == INF) C[i][0] = -INF; else{ C[i][0] = W * ((X-A[i].first+T-1)/T - (Min-A[i].first+T-1)/T + 1) - A[i].second; for (int k=1; k<=M; k++) if (P[k] > Min && P[k]%T == A[i].first) C[i][0] -= W; } } for (int i=1; i<=N; i++){ for (int j=0; j<i; j++){ if (C[i][j] == -INF) D[i][j] = -INF; else D[i][j] = D[i-1][j] + C[i][j]; } for (int j=0; j<i; j++) D[i][i] = max(D[i][i], D[i-1][j]); } for (int i=0; i<=N; i++) ans = max(ans, D[N][i]); ans = -ans; ans += W * ((X+T-1)/T); for (int i=1; i<=N; i++){ ans += W * ((X-A[i].first+T-1)/T); for (int j=1; j<=M; j++) if (P[j]%T == A[i].first) ans -= W; } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 16 ms | 1272 KB | Output is correct |
24 | Correct | 16 ms | 1144 KB | Output is correct |
25 | Correct | 16 ms | 1272 KB | Output is correct |
26 | Correct | 16 ms | 1144 KB | Output is correct |
27 | Correct | 14 ms | 1272 KB | Output is correct |
28 | Correct | 14 ms | 1144 KB | Output is correct |
29 | Correct | 15 ms | 1400 KB | Output is correct |
30 | Correct | 14 ms | 1144 KB | Output is correct |
31 | Correct | 14 ms | 1144 KB | Output is correct |
32 | Correct | 16 ms | 1272 KB | Output is correct |
33 | Correct | 16 ms | 1272 KB | Output is correct |
34 | Correct | 16 ms | 1168 KB | Output is correct |
35 | Correct | 14 ms | 1272 KB | Output is correct |
36 | Correct | 16 ms | 1192 KB | Output is correct |
37 | Correct | 16 ms | 1272 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 16 ms | 1272 KB | Output is correct |
24 | Correct | 16 ms | 1144 KB | Output is correct |
25 | Correct | 16 ms | 1272 KB | Output is correct |
26 | Correct | 16 ms | 1144 KB | Output is correct |
27 | Correct | 14 ms | 1272 KB | Output is correct |
28 | Correct | 14 ms | 1144 KB | Output is correct |
29 | Correct | 15 ms | 1400 KB | Output is correct |
30 | Correct | 14 ms | 1144 KB | Output is correct |
31 | Correct | 14 ms | 1144 KB | Output is correct |
32 | Correct | 16 ms | 1272 KB | Output is correct |
33 | Correct | 16 ms | 1272 KB | Output is correct |
34 | Correct | 16 ms | 1168 KB | Output is correct |
35 | Correct | 14 ms | 1272 KB | Output is correct |
36 | Correct | 16 ms | 1192 KB | Output is correct |
37 | Correct | 16 ms | 1272 KB | Output is correct |
38 | Execution timed out | 2059 ms | 1968 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 16 ms | 1272 KB | Output is correct |
24 | Correct | 16 ms | 1144 KB | Output is correct |
25 | Correct | 16 ms | 1272 KB | Output is correct |
26 | Correct | 16 ms | 1144 KB | Output is correct |
27 | Correct | 14 ms | 1272 KB | Output is correct |
28 | Correct | 14 ms | 1144 KB | Output is correct |
29 | Correct | 15 ms | 1400 KB | Output is correct |
30 | Correct | 14 ms | 1144 KB | Output is correct |
31 | Correct | 14 ms | 1144 KB | Output is correct |
32 | Correct | 16 ms | 1272 KB | Output is correct |
33 | Correct | 16 ms | 1272 KB | Output is correct |
34 | Correct | 16 ms | 1168 KB | Output is correct |
35 | Correct | 14 ms | 1272 KB | Output is correct |
36 | Correct | 16 ms | 1192 KB | Output is correct |
37 | Correct | 16 ms | 1272 KB | Output is correct |
38 | Execution timed out | 2059 ms | 1968 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |