Submission #203345

# Submission time Handle Problem Language Result Execution time Memory
203345 2020-02-20T09:21:20 Z staniewzki Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
83 ms 63864 KB
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
const int N = 201;
int n, len, ans;
int dp[N][N][N][2];
int d[N], t[N];
int main() {
	cin >> n >> len;
	REP(i, n) cin >> d[i + 1];
	REP(i, n) cin >> t[i];
	REP(l, n + 1) REP(r, n + 1) REP(k, n + 1) REP(q, 2) dp[l][r][k][q] = 1e9 + 1;
	dp[0][0][0][0] = 0;
	dp[0][0][0][1] = 0;
	d[n + 1] = len;
	REP(l, n + 1) REP(r, n + 1) {
		if(n < l + r) break;
		REP(k, n + 1) {
			if(l) {
				dp[l][r][k][0] = min(dp[l][r][k][0], dp[l - 1][r][k][0] + d[l] - d[l - 1]);
				dp[l][r][k][0] = min(dp[l][r][k][0], dp[l - 1][r][k][1] + d[l] + len - d[n + 1 - r]);
			}
			if(r) {
				dp[l][r][k][1] = min(dp[l][r][k][1], dp[l][r - 1][k][1] + d[n + 2 - r] - d[n + 1 - r]);
				dp[l][r][k][1] = min(dp[l][r][k][1], dp[l][r - 1][k][0] + d[l] + len - d[n + 1 - r]);
			}
		}
		for(int k = n; k >= 1; k--) {
			if(l && dp[l][r][k - 1][0] <= t[l - 1]) {
				dp[l][r][k][0] = dp[l][r][k - 1][0];
				ans = max(ans, k);
			}
			if(r && dp[l][r][k - 1][1] <= t[n - r]) {
				dp[l][r][k][1] = dp[l][r][k - 1][1];
				ans = max(ans, k);
			}
		}
	}
	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 508 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 5 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 508 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 5 ms 636 KB Output is correct
18 Correct 5 ms 760 KB Output is correct
19 Correct 5 ms 504 KB Output is correct
20 Correct 5 ms 632 KB Output is correct
21 Correct 5 ms 760 KB Output is correct
22 Correct 5 ms 504 KB Output is correct
23 Correct 5 ms 760 KB Output is correct
24 Correct 5 ms 632 KB Output is correct
25 Correct 5 ms 760 KB Output is correct
26 Correct 5 ms 760 KB Output is correct
27 Correct 5 ms 504 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 5 ms 760 KB Output is correct
30 Correct 5 ms 760 KB Output is correct
31 Correct 5 ms 760 KB Output is correct
32 Correct 5 ms 632 KB Output is correct
33 Correct 5 ms 760 KB Output is correct
34 Correct 5 ms 760 KB Output is correct
35 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 508 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 5 ms 636 KB Output is correct
18 Correct 66 ms 52088 KB Output is correct
19 Correct 27 ms 31736 KB Output is correct
20 Correct 18 ms 17016 KB Output is correct
21 Correct 29 ms 29944 KB Output is correct
22 Correct 38 ms 38648 KB Output is correct
23 Correct 15 ms 14584 KB Output is correct
24 Correct 13 ms 11384 KB Output is correct
25 Correct 15 ms 14204 KB Output is correct
26 Correct 11 ms 5624 KB Output is correct
27 Correct 22 ms 14840 KB Output is correct
28 Correct 13 ms 10744 KB Output is correct
29 Correct 18 ms 15096 KB Output is correct
30 Correct 14 ms 12024 KB Output is correct
31 Correct 16 ms 14200 KB Output is correct
32 Correct 10 ms 7672 KB Output is correct
33 Correct 16 ms 14200 KB Output is correct
34 Correct 8 ms 5240 KB Output is correct
35 Correct 16 ms 13944 KB Output is correct
36 Correct 10 ms 6776 KB Output is correct
37 Correct 15 ms 14844 KB Output is correct
38 Correct 10 ms 8184 KB Output is correct
39 Correct 17 ms 15480 KB Output is correct
40 Correct 11 ms 9208 KB Output is correct
41 Correct 78 ms 63608 KB Output is correct
42 Correct 48 ms 43256 KB Output is correct
43 Correct 71 ms 63608 KB Output is correct
44 Correct 44 ms 42744 KB Output is correct
45 Correct 83 ms 63608 KB Output is correct
46 Correct 43 ms 43256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 508 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 5 ms 636 KB Output is correct
18 Correct 5 ms 760 KB Output is correct
19 Correct 5 ms 504 KB Output is correct
20 Correct 5 ms 632 KB Output is correct
21 Correct 5 ms 760 KB Output is correct
22 Correct 5 ms 504 KB Output is correct
23 Correct 5 ms 760 KB Output is correct
24 Correct 5 ms 632 KB Output is correct
25 Correct 5 ms 760 KB Output is correct
26 Correct 5 ms 760 KB Output is correct
27 Correct 5 ms 504 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 5 ms 760 KB Output is correct
30 Correct 5 ms 760 KB Output is correct
31 Correct 5 ms 760 KB Output is correct
32 Correct 5 ms 632 KB Output is correct
33 Correct 5 ms 760 KB Output is correct
34 Correct 5 ms 760 KB Output is correct
35 Correct 5 ms 760 KB Output is correct
36 Correct 66 ms 52088 KB Output is correct
37 Correct 27 ms 31736 KB Output is correct
38 Correct 18 ms 17016 KB Output is correct
39 Correct 29 ms 29944 KB Output is correct
40 Correct 38 ms 38648 KB Output is correct
41 Correct 15 ms 14584 KB Output is correct
42 Correct 13 ms 11384 KB Output is correct
43 Correct 15 ms 14204 KB Output is correct
44 Correct 11 ms 5624 KB Output is correct
45 Correct 22 ms 14840 KB Output is correct
46 Correct 13 ms 10744 KB Output is correct
47 Correct 18 ms 15096 KB Output is correct
48 Correct 14 ms 12024 KB Output is correct
49 Correct 16 ms 14200 KB Output is correct
50 Correct 10 ms 7672 KB Output is correct
51 Correct 16 ms 14200 KB Output is correct
52 Correct 8 ms 5240 KB Output is correct
53 Correct 16 ms 13944 KB Output is correct
54 Correct 10 ms 6776 KB Output is correct
55 Correct 15 ms 14844 KB Output is correct
56 Correct 10 ms 8184 KB Output is correct
57 Correct 17 ms 15480 KB Output is correct
58 Correct 11 ms 9208 KB Output is correct
59 Correct 78 ms 63608 KB Output is correct
60 Correct 48 ms 43256 KB Output is correct
61 Correct 71 ms 63608 KB Output is correct
62 Correct 44 ms 42744 KB Output is correct
63 Correct 83 ms 63608 KB Output is correct
64 Correct 43 ms 43256 KB Output is correct
65 Correct 62 ms 57848 KB Output is correct
66 Correct 54 ms 53112 KB Output is correct
67 Correct 51 ms 50808 KB Output is correct
68 Correct 48 ms 46968 KB Output is correct
69 Correct 60 ms 57208 KB Output is correct
70 Correct 59 ms 54908 KB Output is correct
71 Correct 58 ms 55544 KB Output is correct
72 Correct 60 ms 56056 KB Output is correct
73 Correct 53 ms 51960 KB Output is correct
74 Correct 53 ms 48632 KB Output is correct
75 Correct 56 ms 53752 KB Output is correct
76 Correct 66 ms 61560 KB Output is correct
77 Correct 65 ms 61560 KB Output is correct
78 Correct 49 ms 47584 KB Output is correct
79 Correct 52 ms 49144 KB Output is correct
80 Correct 63 ms 60280 KB Output is correct
81 Correct 51 ms 49784 KB Output is correct
82 Correct 55 ms 52600 KB Output is correct
83 Correct 68 ms 63608 KB Output is correct
84 Correct 59 ms 54904 KB Output is correct
85 Correct 64 ms 59640 KB Output is correct
86 Correct 61 ms 58488 KB Output is correct
87 Correct 59 ms 53752 KB Output is correct
88 Correct 77 ms 63864 KB Output is correct
89 Correct 71 ms 63864 KB Output is correct
90 Correct 56 ms 54264 KB Output is correct
91 Correct 69 ms 63864 KB Output is correct
92 Correct 70 ms 63864 KB Output is correct
93 Correct 69 ms 63224 KB Output is correct