# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56223 | 2018-07-10T10:39:41 Z | andy0220 | None (KOI17_cook) | C++11 | 814 ms | 284592 KB |
#include <bits/stdc++.h> using namespace std; int N, M, S, E, T; int A[3001][3001], B[3001]; int D[3001][3001], C[3001][3001]; struct Z{ int v, t; } mn[3001][3]; deque <Z> dq[3001]; int get_min(int day, int academy) { if (mn[day][0].t != academy && mn[day][0].t != B[academy]) return mn[day][0].v; if (mn[day][1].t != academy && mn[day][1].t != B[academy]) return mn[day][1].v; return mn[day][2].v; } int main() { scanf("%d%d%d%d%d", &N, &M, &S, &E, &T); for (int i=1;i<=N;i++) for (int j=1;j<=M;j++) scanf("%d", A[i]+j); for (int i=1;i<=N;i++) scanf("%d", B+i); for (int i=1;i<=N;i++) for (int j=1;j<=M;j++) C[i][j] = C[i][j-1] + A[i][j]; for (int i=1;i<=M;i++){ for (int j=1;j<=N;j++){ if (i >= S){ int v = get_min(i-S, j) - C[j][i-S]; while (!dq[j].empty() && dq[j].back().v >= v) dq[j].pop_back(); dq[j].push_back({v, i-S}); } while (!dq[j].empty() && dq[j].front().t < i-E) dq[j].pop_front(); if (dq[j].empty() || dq[j].front().v == 1e9) D[i][j] = 1e9; else D[i][j] = dq[j].front().v + T + C[j][i]; } for (int j=0;j<3;j++) mn[i][j] = {(int)1e9, 0}; for (int j=1;j<=N;j++) if (D[i][j] < 1e9){ int v = D[i][j]; if (v < mn[i][0].v) mn[i][2] = mn[i][1], mn[i][1] = mn[i][0], mn[i][0] = {v, j}; else if (v < mn[i][1].v) mn[i][2] = mn[i][1], mn[i][1] = {v, j}; else if (v < mn[i][2].v) mn[i][2] = {v, j}; } } int ans = 1e9; for (int i=1;i<=N;i++){ for (int j=M-E;j<M;j++){ int v = get_min(j, i); if (v == 1e9) continue; ans = min(ans, v + C[i][M]-C[i][j]); } } printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3064 KB | Output is correct |
2 | Correct | 8 ms | 3196 KB | Output is correct |
3 | Correct | 7 ms | 3344 KB | Output is correct |
4 | Correct | 7 ms | 3344 KB | Output is correct |
5 | Correct | 5 ms | 3344 KB | Output is correct |
6 | Correct | 8 ms | 3432 KB | Output is correct |
7 | Correct | 7 ms | 3432 KB | Output is correct |
8 | Correct | 6 ms | 3432 KB | Output is correct |
9 | Correct | 6 ms | 3432 KB | Output is correct |
10 | Correct | 7 ms | 3432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3064 KB | Output is correct |
2 | Correct | 8 ms | 3196 KB | Output is correct |
3 | Correct | 7 ms | 3344 KB | Output is correct |
4 | Correct | 7 ms | 3344 KB | Output is correct |
5 | Correct | 5 ms | 3344 KB | Output is correct |
6 | Correct | 8 ms | 3432 KB | Output is correct |
7 | Correct | 7 ms | 3432 KB | Output is correct |
8 | Correct | 6 ms | 3432 KB | Output is correct |
9 | Correct | 6 ms | 3432 KB | Output is correct |
10 | Correct | 37 ms | 8092 KB | Output is correct |
11 | Correct | 28 ms | 8092 KB | Output is correct |
12 | Correct | 38 ms | 8912 KB | Output is correct |
13 | Correct | 30 ms | 8912 KB | Output is correct |
14 | Correct | 29 ms | 9692 KB | Output is correct |
15 | Correct | 33 ms | 10224 KB | Output is correct |
16 | Correct | 32 ms | 10680 KB | Output is correct |
17 | Correct | 25 ms | 10680 KB | Output is correct |
18 | Correct | 34 ms | 11664 KB | Output is correct |
19 | Correct | 21 ms | 11664 KB | Output is correct |
20 | Correct | 7 ms | 3432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3064 KB | Output is correct |
2 | Correct | 8 ms | 3196 KB | Output is correct |
3 | Correct | 7 ms | 3344 KB | Output is correct |
4 | Correct | 7 ms | 3344 KB | Output is correct |
5 | Correct | 5 ms | 3344 KB | Output is correct |
6 | Correct | 8 ms | 3432 KB | Output is correct |
7 | Correct | 7 ms | 3432 KB | Output is correct |
8 | Correct | 6 ms | 3432 KB | Output is correct |
9 | Correct | 6 ms | 3432 KB | Output is correct |
10 | Correct | 37 ms | 8092 KB | Output is correct |
11 | Correct | 28 ms | 8092 KB | Output is correct |
12 | Correct | 38 ms | 8912 KB | Output is correct |
13 | Correct | 30 ms | 8912 KB | Output is correct |
14 | Correct | 29 ms | 9692 KB | Output is correct |
15 | Correct | 33 ms | 10224 KB | Output is correct |
16 | Correct | 32 ms | 10680 KB | Output is correct |
17 | Correct | 25 ms | 10680 KB | Output is correct |
18 | Correct | 34 ms | 11664 KB | Output is correct |
19 | Correct | 21 ms | 11664 KB | Output is correct |
20 | Correct | 329 ms | 46828 KB | Output is correct |
21 | Correct | 230 ms | 51652 KB | Output is correct |
22 | Correct | 192 ms | 56580 KB | Output is correct |
23 | Correct | 183 ms | 61660 KB | Output is correct |
24 | Correct | 163 ms | 66420 KB | Output is correct |
25 | Correct | 198 ms | 71300 KB | Output is correct |
26 | Correct | 194 ms | 76224 KB | Output is correct |
27 | Correct | 188 ms | 81132 KB | Output is correct |
28 | Correct | 200 ms | 86020 KB | Output is correct |
29 | Correct | 165 ms | 91096 KB | Output is correct |
30 | Correct | 7 ms | 3432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3064 KB | Output is correct |
2 | Correct | 8 ms | 3196 KB | Output is correct |
3 | Correct | 7 ms | 3344 KB | Output is correct |
4 | Correct | 7 ms | 3344 KB | Output is correct |
5 | Correct | 5 ms | 3344 KB | Output is correct |
6 | Correct | 8 ms | 3432 KB | Output is correct |
7 | Correct | 7 ms | 3432 KB | Output is correct |
8 | Correct | 6 ms | 3432 KB | Output is correct |
9 | Correct | 6 ms | 3432 KB | Output is correct |
10 | Correct | 37 ms | 8092 KB | Output is correct |
11 | Correct | 28 ms | 8092 KB | Output is correct |
12 | Correct | 38 ms | 8912 KB | Output is correct |
13 | Correct | 30 ms | 8912 KB | Output is correct |
14 | Correct | 29 ms | 9692 KB | Output is correct |
15 | Correct | 33 ms | 10224 KB | Output is correct |
16 | Correct | 32 ms | 10680 KB | Output is correct |
17 | Correct | 25 ms | 10680 KB | Output is correct |
18 | Correct | 34 ms | 11664 KB | Output is correct |
19 | Correct | 21 ms | 11664 KB | Output is correct |
20 | Correct | 173 ms | 91096 KB | Output is correct |
21 | Correct | 171 ms | 91096 KB | Output is correct |
22 | Correct | 203 ms | 93508 KB | Output is correct |
23 | Correct | 150 ms | 98624 KB | Output is correct |
24 | Correct | 186 ms | 103472 KB | Output is correct |
25 | Correct | 158 ms | 108452 KB | Output is correct |
26 | Correct | 174 ms | 113244 KB | Output is correct |
27 | Correct | 166 ms | 118008 KB | Output is correct |
28 | Correct | 174 ms | 122904 KB | Output is correct |
29 | Correct | 158 ms | 127796 KB | Output is correct |
30 | Correct | 7 ms | 3432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3064 KB | Output is correct |
2 | Correct | 8 ms | 3196 KB | Output is correct |
3 | Correct | 7 ms | 3344 KB | Output is correct |
4 | Correct | 7 ms | 3344 KB | Output is correct |
5 | Correct | 5 ms | 3344 KB | Output is correct |
6 | Correct | 8 ms | 3432 KB | Output is correct |
7 | Correct | 7 ms | 3432 KB | Output is correct |
8 | Correct | 6 ms | 3432 KB | Output is correct |
9 | Correct | 6 ms | 3432 KB | Output is correct |
10 | Correct | 37 ms | 8092 KB | Output is correct |
11 | Correct | 28 ms | 8092 KB | Output is correct |
12 | Correct | 38 ms | 8912 KB | Output is correct |
13 | Correct | 30 ms | 8912 KB | Output is correct |
14 | Correct | 29 ms | 9692 KB | Output is correct |
15 | Correct | 33 ms | 10224 KB | Output is correct |
16 | Correct | 32 ms | 10680 KB | Output is correct |
17 | Correct | 25 ms | 10680 KB | Output is correct |
18 | Correct | 34 ms | 11664 KB | Output is correct |
19 | Correct | 21 ms | 11664 KB | Output is correct |
20 | Correct | 329 ms | 46828 KB | Output is correct |
21 | Correct | 230 ms | 51652 KB | Output is correct |
22 | Correct | 192 ms | 56580 KB | Output is correct |
23 | Correct | 183 ms | 61660 KB | Output is correct |
24 | Correct | 163 ms | 66420 KB | Output is correct |
25 | Correct | 198 ms | 71300 KB | Output is correct |
26 | Correct | 194 ms | 76224 KB | Output is correct |
27 | Correct | 188 ms | 81132 KB | Output is correct |
28 | Correct | 200 ms | 86020 KB | Output is correct |
29 | Correct | 165 ms | 91096 KB | Output is correct |
30 | Correct | 173 ms | 91096 KB | Output is correct |
31 | Correct | 171 ms | 91096 KB | Output is correct |
32 | Correct | 203 ms | 93508 KB | Output is correct |
33 | Correct | 150 ms | 98624 KB | Output is correct |
34 | Correct | 186 ms | 103472 KB | Output is correct |
35 | Correct | 158 ms | 108452 KB | Output is correct |
36 | Correct | 174 ms | 113244 KB | Output is correct |
37 | Correct | 166 ms | 118008 KB | Output is correct |
38 | Correct | 174 ms | 122904 KB | Output is correct |
39 | Correct | 158 ms | 127796 KB | Output is correct |
40 | Correct | 227 ms | 137812 KB | Output is correct |
41 | Correct | 615 ms | 175440 KB | Output is correct |
42 | Correct | 658 ms | 191708 KB | Output is correct |
43 | Correct | 626 ms | 219976 KB | Output is correct |
44 | Correct | 261 ms | 219976 KB | Output is correct |
45 | Correct | 304 ms | 219976 KB | Output is correct |
46 | Correct | 345 ms | 226612 KB | Output is correct |
47 | Correct | 445 ms | 248388 KB | Output is correct |
48 | Correct | 583 ms | 268224 KB | Output is correct |
49 | Correct | 814 ms | 284592 KB | Output is correct |
50 | Correct | 7 ms | 3432 KB | Output is correct |