# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
393605 | 2021-04-24T05:39:51 Z | 79brue | Collecting Stamps 3 (JOI20_ho_t3) | C++14 | 129 ms | 134472 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; ll l; ll arr[205], t[205]; ll DP[205][205][205][2]; /// l에 있는 경우 = 0, r에 있는 경우 = 1 int ans; int main(){ scanf("%d %lld", &n, &l); for(int i=1; i<=n; i++) scanf("%lld", &arr[i]); for(int i=1; i<=n; i++) scanf("%lld", &t[i]); arr[n+1] = l; for(int i=0; i<=n+3; i++) for(int j=0; j<=n+3; j++) for(int k=0; k<=n+3; k++) DP[i][j][k][0] = DP[i][j][k][1] = 1e18; DP[0][n+1][0][0] = DP[0][n+1][0][1] = 0; for(int d=n+1; d>0; d--){ for(int i=0; i<=n+1-d; i++){ int j = i+d; for(int p=0; p<=n; p++){ ll newT; int newP; if(DP[i][j][p][0] < 1e18){ /// 현재 i에 있는 경우 ans = max(ans, p); if(d){ newT = DP[i][j][p][0] + (arr[i+1] - arr[i]); newP = p + (newT <= t[i+1]); DP[i+1][j][newP][0] = min(DP[i+1][j][newP][0], newT); newT = DP[i][j][p][0] + l - (arr[j-1] - arr[i]); newP = p + (newT <= t[j-1]); DP[i][j-1][newP][1] = min(DP[i][j-1][newP][1], newT); } } if(DP[i][j][p][1] < 1e18){ ans = max(ans, p); if(d){ newT = DP[i][j][p][1] + l - (arr[j] - arr[i+1]); newP = p + (newT <= t[i+1]); DP[i+1][j][newP][0] = min(DP[i+1][j][newP][0], newT); newT = DP[i][j][p][1] + (arr[j] - arr[j-1]); newP = p + (newT <= t[j-1]); DP[i][j-1][newP][1] = min(DP[i][j-1][newP][1], newT); } } } } } printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 844 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 1100 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 844 KB | Output is correct |
9 | Correct | 1 ms | 1100 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 1100 KB | Output is correct |
13 | Correct | 1 ms | 1100 KB | Output is correct |
14 | Correct | 1 ms | 588 KB | Output is correct |
15 | Correct | 1 ms | 716 KB | Output is correct |
16 | Correct | 1 ms | 1100 KB | Output is correct |
17 | Correct | 1 ms | 1100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 844 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 1100 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 844 KB | Output is correct |
9 | Correct | 1 ms | 1100 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 1100 KB | Output is correct |
13 | Correct | 1 ms | 1100 KB | Output is correct |
14 | Correct | 1 ms | 588 KB | Output is correct |
15 | Correct | 1 ms | 716 KB | Output is correct |
16 | Correct | 1 ms | 1100 KB | Output is correct |
17 | Correct | 1 ms | 1100 KB | Output is correct |
18 | Correct | 1 ms | 1356 KB | Output is correct |
19 | Correct | 1 ms | 844 KB | Output is correct |
20 | Correct | 1 ms | 1100 KB | Output is correct |
21 | Correct | 1 ms | 1320 KB | Output is correct |
22 | Correct | 1 ms | 844 KB | Output is correct |
23 | Correct | 1 ms | 1484 KB | Output is correct |
24 | Correct | 1 ms | 1228 KB | Output is correct |
25 | Correct | 1 ms | 1356 KB | Output is correct |
26 | Correct | 1 ms | 1356 KB | Output is correct |
27 | Correct | 1 ms | 716 KB | Output is correct |
28 | Correct | 1 ms | 844 KB | Output is correct |
29 | Correct | 1 ms | 1476 KB | Output is correct |
30 | Correct | 1 ms | 1484 KB | Output is correct |
31 | Correct | 1 ms | 1356 KB | Output is correct |
32 | Correct | 1 ms | 1232 KB | Output is correct |
33 | Correct | 1 ms | 1484 KB | Output is correct |
34 | Correct | 1 ms | 1484 KB | Output is correct |
35 | Correct | 1 ms | 1484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 844 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 1100 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 844 KB | Output is correct |
9 | Correct | 1 ms | 1100 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 1100 KB | Output is correct |
13 | Correct | 1 ms | 1100 KB | Output is correct |
14 | Correct | 1 ms | 588 KB | Output is correct |
15 | Correct | 1 ms | 716 KB | Output is correct |
16 | Correct | 1 ms | 1100 KB | Output is correct |
17 | Correct | 1 ms | 1100 KB | Output is correct |
18 | Correct | 85 ms | 108456 KB | Output is correct |
19 | Correct | 48 ms | 66412 KB | Output is correct |
20 | Correct | 23 ms | 35916 KB | Output is correct |
21 | Correct | 45 ms | 62688 KB | Output is correct |
22 | Correct | 61 ms | 81056 KB | Output is correct |
23 | Correct | 22 ms | 30668 KB | Output is correct |
24 | Correct | 14 ms | 24268 KB | Output is correct |
25 | Correct | 21 ms | 30164 KB | Output is correct |
26 | Correct | 7 ms | 11952 KB | Output is correct |
27 | Correct | 22 ms | 31316 KB | Output is correct |
28 | Correct | 13 ms | 22636 KB | Output is correct |
29 | Correct | 21 ms | 31948 KB | Output is correct |
30 | Correct | 15 ms | 25292 KB | Output is correct |
31 | Correct | 20 ms | 30044 KB | Output is correct |
32 | Correct | 10 ms | 16172 KB | Output is correct |
33 | Correct | 19 ms | 30128 KB | Output is correct |
34 | Correct | 6 ms | 11188 KB | Output is correct |
35 | Correct | 17 ms | 29540 KB | Output is correct |
36 | Correct | 8 ms | 14380 KB | Output is correct |
37 | Correct | 18 ms | 31296 KB | Output is correct |
38 | Correct | 10 ms | 17612 KB | Output is correct |
39 | Correct | 19 ms | 32704 KB | Output is correct |
40 | Correct | 11 ms | 19532 KB | Output is correct |
41 | Correct | 120 ms | 133352 KB | Output is correct |
42 | Correct | 52 ms | 90328 KB | Output is correct |
43 | Correct | 117 ms | 133456 KB | Output is correct |
44 | Correct | 50 ms | 89284 KB | Output is correct |
45 | Correct | 117 ms | 133348 KB | Output is correct |
46 | Correct | 51 ms | 90404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 844 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 1 ms | 1100 KB | Output is correct |
7 | Correct | 1 ms | 716 KB | Output is correct |
8 | Correct | 1 ms | 844 KB | Output is correct |
9 | Correct | 1 ms | 1100 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 1100 KB | Output is correct |
13 | Correct | 1 ms | 1100 KB | Output is correct |
14 | Correct | 1 ms | 588 KB | Output is correct |
15 | Correct | 1 ms | 716 KB | Output is correct |
16 | Correct | 1 ms | 1100 KB | Output is correct |
17 | Correct | 1 ms | 1100 KB | Output is correct |
18 | Correct | 1 ms | 1356 KB | Output is correct |
19 | Correct | 1 ms | 844 KB | Output is correct |
20 | Correct | 1 ms | 1100 KB | Output is correct |
21 | Correct | 1 ms | 1320 KB | Output is correct |
22 | Correct | 1 ms | 844 KB | Output is correct |
23 | Correct | 1 ms | 1484 KB | Output is correct |
24 | Correct | 1 ms | 1228 KB | Output is correct |
25 | Correct | 1 ms | 1356 KB | Output is correct |
26 | Correct | 1 ms | 1356 KB | Output is correct |
27 | Correct | 1 ms | 716 KB | Output is correct |
28 | Correct | 1 ms | 844 KB | Output is correct |
29 | Correct | 1 ms | 1476 KB | Output is correct |
30 | Correct | 1 ms | 1484 KB | Output is correct |
31 | Correct | 1 ms | 1356 KB | Output is correct |
32 | Correct | 1 ms | 1232 KB | Output is correct |
33 | Correct | 1 ms | 1484 KB | Output is correct |
34 | Correct | 1 ms | 1484 KB | Output is correct |
35 | Correct | 1 ms | 1484 KB | Output is correct |
36 | Correct | 85 ms | 108456 KB | Output is correct |
37 | Correct | 48 ms | 66412 KB | Output is correct |
38 | Correct | 23 ms | 35916 KB | Output is correct |
39 | Correct | 45 ms | 62688 KB | Output is correct |
40 | Correct | 61 ms | 81056 KB | Output is correct |
41 | Correct | 22 ms | 30668 KB | Output is correct |
42 | Correct | 14 ms | 24268 KB | Output is correct |
43 | Correct | 21 ms | 30164 KB | Output is correct |
44 | Correct | 7 ms | 11952 KB | Output is correct |
45 | Correct | 22 ms | 31316 KB | Output is correct |
46 | Correct | 13 ms | 22636 KB | Output is correct |
47 | Correct | 21 ms | 31948 KB | Output is correct |
48 | Correct | 15 ms | 25292 KB | Output is correct |
49 | Correct | 20 ms | 30044 KB | Output is correct |
50 | Correct | 10 ms | 16172 KB | Output is correct |
51 | Correct | 19 ms | 30128 KB | Output is correct |
52 | Correct | 6 ms | 11188 KB | Output is correct |
53 | Correct | 17 ms | 29540 KB | Output is correct |
54 | Correct | 8 ms | 14380 KB | Output is correct |
55 | Correct | 18 ms | 31296 KB | Output is correct |
56 | Correct | 10 ms | 17612 KB | Output is correct |
57 | Correct | 19 ms | 32704 KB | Output is correct |
58 | Correct | 11 ms | 19532 KB | Output is correct |
59 | Correct | 120 ms | 133352 KB | Output is correct |
60 | Correct | 52 ms | 90328 KB | Output is correct |
61 | Correct | 117 ms | 133456 KB | Output is correct |
62 | Correct | 50 ms | 89284 KB | Output is correct |
63 | Correct | 117 ms | 133348 KB | Output is correct |
64 | Correct | 51 ms | 90404 KB | Output is correct |
65 | Correct | 98 ms | 120628 KB | Output is correct |
66 | Correct | 91 ms | 110832 KB | Output is correct |
67 | Correct | 84 ms | 106184 KB | Output is correct |
68 | Correct | 76 ms | 98028 KB | Output is correct |
69 | Correct | 97 ms | 119308 KB | Output is correct |
70 | Correct | 104 ms | 114500 KB | Output is correct |
71 | Correct | 92 ms | 115652 KB | Output is correct |
72 | Correct | 106 ms | 116860 KB | Output is correct |
73 | Correct | 75 ms | 108380 KB | Output is correct |
74 | Correct | 87 ms | 101504 KB | Output is correct |
75 | Correct | 88 ms | 111964 KB | Output is correct |
76 | Correct | 112 ms | 128068 KB | Output is correct |
77 | Correct | 106 ms | 128136 KB | Output is correct |
78 | Correct | 83 ms | 99224 KB | Output is correct |
79 | Correct | 80 ms | 102596 KB | Output is correct |
80 | Correct | 111 ms | 125636 KB | Output is correct |
81 | Correct | 79 ms | 103672 KB | Output is correct |
82 | Correct | 79 ms | 109636 KB | Output is correct |
83 | Correct | 114 ms | 133348 KB | Output is correct |
84 | Correct | 84 ms | 114332 KB | Output is correct |
85 | Correct | 92 ms | 124228 KB | Output is correct |
86 | Correct | 91 ms | 121820 KB | Output is correct |
87 | Correct | 92 ms | 111940 KB | Output is correct |
88 | Correct | 128 ms | 134468 KB | Output is correct |
89 | Correct | 118 ms | 134472 KB | Output is correct |
90 | Correct | 66 ms | 113172 KB | Output is correct |
91 | Correct | 129 ms | 134428 KB | Output is correct |
92 | Correct | 117 ms | 134440 KB | Output is correct |
93 | Correct | 79 ms | 131984 KB | Output is correct |