Submission #520964

# Submission time Handle Problem Language Result Execution time Memory
520964 2022-01-31T14:49:13 Z AdamGS Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
51 ms 66556 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=207, INF=1e9+7;
int X[LIM], T[LIM], dp[LIM][LIM][LIM][2];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m, ans=0;
	cin >> n >> m;
	rep(i, n) cin >> X[i+1];
	rep(i, n) cin >> T[i+1];
	rep(i, n+1) rep(j, n+1) rep(c, n+1) rep(l, 2) dp[i][j][c][l]=INF;
	dp[0][0][0][0]=0;
	rep(i, n+1) rep(j, n-i+1) rep(c, i+j+1) rep(l, 2) if(dp[i][j][c][l]<INF) {
		ans=max(ans, c);
		if(i+j==n) continue;
		int x=dp[i][j][c][l];
		if(!l) {
			dp[i+1][j][c][0]=min(dp[i+1][j][c][0], x+X[i+1]-X[i]);
			if(x+X[i+1]-X[i]<=T[i+1]) {
				dp[i+1][j][c+1][0]=min(dp[i+1][j][c+1][0], x+X[i+1]-X[i]);
			}
			dp[i][j+1][c][1]=min(dp[i][j+1][c][1], x+X[i]+m-X[n-j]);
			if(x+X[i]+m-X[n-j]<=T[n-j]) {
				dp[i][j+1][c+1][1]=min(dp[i][j+1][c+1][1], x+X[i]+m-X[n-j]);
			}
		} else {
			dp[i+1][j][c][0]=min(dp[i+1][j][c][0], x+m-X[n-j+1]+X[i+1]);
			if(x+m-X[n-j+1]+X[i+1]<=T[i+1]) {
				dp[i+1][j][c+1][0]=min(dp[i+1][j][c+1][0], x+m-X[n-j+1]+X[i+1]);
			}
			dp[i][j+1][c][1]=min(dp[i][j+1][c][1], x+X[n-j+1]-X[n-j]);
			if(x+X[n-j+1]-X[n-j]<=T[n-j]) {
				dp[i][j+1][c+1][1]=min(dp[i][j+1][c+1][1], x+X[n-j+1]-X[n-j]);
			}
		}
	}
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 584 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 584 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 720 KB Output is correct
19 Correct 1 ms 452 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 720 KB Output is correct
22 Correct 0 ms 476 KB Output is correct
23 Correct 1 ms 720 KB Output is correct
24 Correct 1 ms 580 KB Output is correct
25 Correct 1 ms 720 KB Output is correct
26 Correct 1 ms 720 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 464 KB Output is correct
29 Correct 1 ms 720 KB Output is correct
30 Correct 1 ms 720 KB Output is correct
31 Correct 1 ms 700 KB Output is correct
32 Correct 1 ms 572 KB Output is correct
33 Correct 1 ms 720 KB Output is correct
34 Correct 1 ms 720 KB Output is correct
35 Correct 1 ms 712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 584 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 35 ms 53500 KB Output is correct
19 Correct 20 ms 32464 KB Output is correct
20 Correct 12 ms 17484 KB Output is correct
21 Correct 20 ms 30788 KB Output is correct
22 Correct 26 ms 39792 KB Output is correct
23 Correct 10 ms 14912 KB Output is correct
24 Correct 8 ms 11664 KB Output is correct
25 Correct 9 ms 14560 KB Output is correct
26 Correct 4 ms 5712 KB Output is correct
27 Correct 10 ms 15212 KB Output is correct
28 Correct 6 ms 10832 KB Output is correct
29 Correct 9 ms 15468 KB Output is correct
30 Correct 7 ms 12228 KB Output is correct
31 Correct 9 ms 14544 KB Output is correct
32 Correct 4 ms 7760 KB Output is correct
33 Correct 11 ms 14544 KB Output is correct
34 Correct 3 ms 5328 KB Output is correct
35 Correct 9 ms 14280 KB Output is correct
36 Correct 4 ms 6848 KB Output is correct
37 Correct 10 ms 15168 KB Output is correct
38 Correct 5 ms 8384 KB Output is correct
39 Correct 10 ms 15812 KB Output is correct
40 Correct 5 ms 9424 KB Output is correct
41 Correct 46 ms 65828 KB Output is correct
42 Correct 24 ms 44468 KB Output is correct
43 Correct 46 ms 65860 KB Output is correct
44 Correct 30 ms 43920 KB Output is correct
45 Correct 47 ms 65900 KB Output is correct
46 Correct 27 ms 44488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 584 KB Output is correct
7 Correct 1 ms 448 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 720 KB Output is correct
19 Correct 1 ms 452 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 720 KB Output is correct
22 Correct 0 ms 476 KB Output is correct
23 Correct 1 ms 720 KB Output is correct
24 Correct 1 ms 580 KB Output is correct
25 Correct 1 ms 720 KB Output is correct
26 Correct 1 ms 720 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 464 KB Output is correct
29 Correct 1 ms 720 KB Output is correct
30 Correct 1 ms 720 KB Output is correct
31 Correct 1 ms 700 KB Output is correct
32 Correct 1 ms 572 KB Output is correct
33 Correct 1 ms 720 KB Output is correct
34 Correct 1 ms 720 KB Output is correct
35 Correct 1 ms 712 KB Output is correct
36 Correct 35 ms 53500 KB Output is correct
37 Correct 20 ms 32464 KB Output is correct
38 Correct 12 ms 17484 KB Output is correct
39 Correct 20 ms 30788 KB Output is correct
40 Correct 26 ms 39792 KB Output is correct
41 Correct 10 ms 14912 KB Output is correct
42 Correct 8 ms 11664 KB Output is correct
43 Correct 9 ms 14560 KB Output is correct
44 Correct 4 ms 5712 KB Output is correct
45 Correct 10 ms 15212 KB Output is correct
46 Correct 6 ms 10832 KB Output is correct
47 Correct 9 ms 15468 KB Output is correct
48 Correct 7 ms 12228 KB Output is correct
49 Correct 9 ms 14544 KB Output is correct
50 Correct 4 ms 7760 KB Output is correct
51 Correct 11 ms 14544 KB Output is correct
52 Correct 3 ms 5328 KB Output is correct
53 Correct 9 ms 14280 KB Output is correct
54 Correct 4 ms 6848 KB Output is correct
55 Correct 10 ms 15168 KB Output is correct
56 Correct 5 ms 8384 KB Output is correct
57 Correct 10 ms 15812 KB Output is correct
58 Correct 5 ms 9424 KB Output is correct
59 Correct 46 ms 65828 KB Output is correct
60 Correct 24 ms 44468 KB Output is correct
61 Correct 46 ms 65860 KB Output is correct
62 Correct 30 ms 43920 KB Output is correct
63 Correct 47 ms 65900 KB Output is correct
64 Correct 27 ms 44488 KB Output is correct
65 Correct 38 ms 59464 KB Output is correct
66 Correct 34 ms 54676 KB Output is correct
67 Correct 32 ms 52256 KB Output is correct
68 Correct 31 ms 48336 KB Output is correct
69 Correct 38 ms 58824 KB Output is correct
70 Correct 41 ms 56404 KB Output is correct
71 Correct 36 ms 57032 KB Output is correct
72 Correct 38 ms 57608 KB Output is correct
73 Correct 32 ms 53448 KB Output is correct
74 Correct 33 ms 50000 KB Output is correct
75 Correct 33 ms 55232 KB Output is correct
76 Correct 43 ms 63312 KB Output is correct
77 Correct 38 ms 63308 KB Output is correct
78 Correct 32 ms 48824 KB Output is correct
79 Correct 31 ms 50512 KB Output is correct
80 Correct 42 ms 62032 KB Output is correct
81 Correct 32 ms 51144 KB Output is correct
82 Correct 34 ms 54020 KB Output is correct
83 Correct 40 ms 65892 KB Output is correct
84 Correct 37 ms 56372 KB Output is correct
85 Correct 35 ms 61340 KB Output is correct
86 Correct 39 ms 60112 KB Output is correct
87 Correct 36 ms 55164 KB Output is correct
88 Correct 47 ms 66488 KB Output is correct
89 Correct 40 ms 66512 KB Output is correct
90 Correct 30 ms 55760 KB Output is correct
91 Correct 51 ms 66472 KB Output is correct
92 Correct 41 ms 66556 KB Output is correct
93 Correct 37 ms 65224 KB Output is correct