Submission #532540

# Submission time Handle Problem Language Result Execution time Memory
532540 2022-03-03T06:27:19 Z amunduzbaev Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
128 ms 135244 KB
#include "bits/stdc++.h"
using namespace std;

#define ar array
#define int long long

const int N = 205;
int dp[2][N][N][N];
int x[N], t[N];

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, L; cin>>n>>L;
	for(int i=1;i<=n;i++) cin>>x[i];
	for(int i=1;i<=n;i++) cin>>t[i];
	x[n + 1] = L;
	
	memset(dp, 127, sizeof dp);
	int MX = dp[0][0][0][0];
	dp[0][0][n+1][0] = 
	dp[1][0][n+1][0] = 0;

	int res = 0;
	for(int c=0;c<=n;c++){
		for(int l=0;l<=n;l++){
			for(int r=n+1;r>l;r--){
				dp[0][l][r][c] = min(dp[0][l][r][c], dp[1][l][r][c] + L - x[r] + x[l]);
				dp[1][l][r][c] = min(dp[1][l][r][c], dp[0][l][r][c] + L - x[r] + x[l]);
				if(dp[0][l][r][c] < MX) res = max(res, c);
				if(dp[1][l][r][c] < MX) res = max(res, c);
				//~ if(l == 0 && r == 1){
					//~ cout<<l<<" "<<r<<" "<<c<<" "<<dp[0][l][r][c]<<" "<<dp[1][l][r][c]<<"\n";
				//~ }


				dp[0][l+1][r][c] = min(dp[0][l+1][r][c], dp[0][l][r][c] + x[l+1] - x[l]);
				if(dp[0][l][r][c] + x[l+1] - x[l] <= t[l+1]){
					dp[0][l+1][r][c+1] = min(dp[0][l+1][r][c+1], dp[0][l][r][c] + x[l+1] - x[l]);
				}
				dp[1][l][r-1][c] = min(dp[1][l][r-1][c], dp[1][l][r][c] + x[r] - x[r-1]);
				if(dp[1][l][r][c] + x[r] - x[r-1] <= t[r-1]){
					dp[1][l][r-1][c+1] = min(dp[1][l][r-1][c+1], dp[1][l][r][c] + x[r] - x[r-1]);
				}
			}
		}
	}
	
	cout<<res<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 53 ms 135244 KB Output is correct
2 Correct 50 ms 135120 KB Output is correct
3 Correct 51 ms 135100 KB Output is correct
4 Correct 51 ms 135144 KB Output is correct
5 Correct 52 ms 135116 KB Output is correct
6 Correct 52 ms 135088 KB Output is correct
7 Correct 51 ms 135116 KB Output is correct
8 Correct 51 ms 135064 KB Output is correct
9 Correct 57 ms 135124 KB Output is correct
10 Correct 53 ms 135072 KB Output is correct
11 Correct 54 ms 135116 KB Output is correct
12 Correct 54 ms 135060 KB Output is correct
13 Correct 58 ms 135060 KB Output is correct
14 Correct 53 ms 135052 KB Output is correct
15 Correct 53 ms 135108 KB Output is correct
16 Correct 53 ms 135120 KB Output is correct
17 Correct 57 ms 135100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 135244 KB Output is correct
2 Correct 50 ms 135120 KB Output is correct
3 Correct 51 ms 135100 KB Output is correct
4 Correct 51 ms 135144 KB Output is correct
5 Correct 52 ms 135116 KB Output is correct
6 Correct 52 ms 135088 KB Output is correct
7 Correct 51 ms 135116 KB Output is correct
8 Correct 51 ms 135064 KB Output is correct
9 Correct 57 ms 135124 KB Output is correct
10 Correct 53 ms 135072 KB Output is correct
11 Correct 54 ms 135116 KB Output is correct
12 Correct 54 ms 135060 KB Output is correct
13 Correct 58 ms 135060 KB Output is correct
14 Correct 53 ms 135052 KB Output is correct
15 Correct 53 ms 135108 KB Output is correct
16 Correct 53 ms 135120 KB Output is correct
17 Correct 57 ms 135100 KB Output is correct
18 Correct 53 ms 135112 KB Output is correct
19 Correct 53 ms 135060 KB Output is correct
20 Correct 52 ms 135148 KB Output is correct
21 Correct 59 ms 135096 KB Output is correct
22 Correct 53 ms 135072 KB Output is correct
23 Correct 54 ms 135076 KB Output is correct
24 Correct 57 ms 135080 KB Output is correct
25 Correct 53 ms 135092 KB Output is correct
26 Correct 53 ms 135148 KB Output is correct
27 Correct 60 ms 135104 KB Output is correct
28 Correct 53 ms 135108 KB Output is correct
29 Correct 54 ms 135132 KB Output is correct
30 Correct 53 ms 135136 KB Output is correct
31 Correct 59 ms 135112 KB Output is correct
32 Correct 54 ms 135100 KB Output is correct
33 Correct 53 ms 135116 KB Output is correct
34 Correct 53 ms 135200 KB Output is correct
35 Correct 54 ms 135084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 135244 KB Output is correct
2 Correct 50 ms 135120 KB Output is correct
3 Correct 51 ms 135100 KB Output is correct
4 Correct 51 ms 135144 KB Output is correct
5 Correct 52 ms 135116 KB Output is correct
6 Correct 52 ms 135088 KB Output is correct
7 Correct 51 ms 135116 KB Output is correct
8 Correct 51 ms 135064 KB Output is correct
9 Correct 57 ms 135124 KB Output is correct
10 Correct 53 ms 135072 KB Output is correct
11 Correct 54 ms 135116 KB Output is correct
12 Correct 54 ms 135060 KB Output is correct
13 Correct 58 ms 135060 KB Output is correct
14 Correct 53 ms 135052 KB Output is correct
15 Correct 53 ms 135108 KB Output is correct
16 Correct 53 ms 135120 KB Output is correct
17 Correct 57 ms 135100 KB Output is correct
18 Correct 97 ms 135104 KB Output is correct
19 Correct 78 ms 135108 KB Output is correct
20 Correct 69 ms 135096 KB Output is correct
21 Correct 71 ms 135104 KB Output is correct
22 Correct 80 ms 135128 KB Output is correct
23 Correct 60 ms 135116 KB Output is correct
24 Correct 57 ms 135056 KB Output is correct
25 Correct 59 ms 135060 KB Output is correct
26 Correct 58 ms 135156 KB Output is correct
27 Correct 59 ms 135172 KB Output is correct
28 Correct 61 ms 135152 KB Output is correct
29 Correct 60 ms 135108 KB Output is correct
30 Correct 57 ms 135120 KB Output is correct
31 Correct 62 ms 135108 KB Output is correct
32 Correct 60 ms 135116 KB Output is correct
33 Correct 59 ms 135084 KB Output is correct
34 Correct 55 ms 135088 KB Output is correct
35 Correct 59 ms 135116 KB Output is correct
36 Correct 54 ms 135108 KB Output is correct
37 Correct 61 ms 135108 KB Output is correct
38 Correct 56 ms 135152 KB Output is correct
39 Correct 62 ms 135140 KB Output is correct
40 Correct 57 ms 135068 KB Output is correct
41 Correct 128 ms 135172 KB Output is correct
42 Correct 86 ms 135176 KB Output is correct
43 Correct 117 ms 135108 KB Output is correct
44 Correct 85 ms 135172 KB Output is correct
45 Correct 124 ms 135208 KB Output is correct
46 Correct 85 ms 135172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 135244 KB Output is correct
2 Correct 50 ms 135120 KB Output is correct
3 Correct 51 ms 135100 KB Output is correct
4 Correct 51 ms 135144 KB Output is correct
5 Correct 52 ms 135116 KB Output is correct
6 Correct 52 ms 135088 KB Output is correct
7 Correct 51 ms 135116 KB Output is correct
8 Correct 51 ms 135064 KB Output is correct
9 Correct 57 ms 135124 KB Output is correct
10 Correct 53 ms 135072 KB Output is correct
11 Correct 54 ms 135116 KB Output is correct
12 Correct 54 ms 135060 KB Output is correct
13 Correct 58 ms 135060 KB Output is correct
14 Correct 53 ms 135052 KB Output is correct
15 Correct 53 ms 135108 KB Output is correct
16 Correct 53 ms 135120 KB Output is correct
17 Correct 57 ms 135100 KB Output is correct
18 Correct 53 ms 135112 KB Output is correct
19 Correct 53 ms 135060 KB Output is correct
20 Correct 52 ms 135148 KB Output is correct
21 Correct 59 ms 135096 KB Output is correct
22 Correct 53 ms 135072 KB Output is correct
23 Correct 54 ms 135076 KB Output is correct
24 Correct 57 ms 135080 KB Output is correct
25 Correct 53 ms 135092 KB Output is correct
26 Correct 53 ms 135148 KB Output is correct
27 Correct 60 ms 135104 KB Output is correct
28 Correct 53 ms 135108 KB Output is correct
29 Correct 54 ms 135132 KB Output is correct
30 Correct 53 ms 135136 KB Output is correct
31 Correct 59 ms 135112 KB Output is correct
32 Correct 54 ms 135100 KB Output is correct
33 Correct 53 ms 135116 KB Output is correct
34 Correct 53 ms 135200 KB Output is correct
35 Correct 54 ms 135084 KB Output is correct
36 Correct 97 ms 135104 KB Output is correct
37 Correct 78 ms 135108 KB Output is correct
38 Correct 69 ms 135096 KB Output is correct
39 Correct 71 ms 135104 KB Output is correct
40 Correct 80 ms 135128 KB Output is correct
41 Correct 60 ms 135116 KB Output is correct
42 Correct 57 ms 135056 KB Output is correct
43 Correct 59 ms 135060 KB Output is correct
44 Correct 58 ms 135156 KB Output is correct
45 Correct 59 ms 135172 KB Output is correct
46 Correct 61 ms 135152 KB Output is correct
47 Correct 60 ms 135108 KB Output is correct
48 Correct 57 ms 135120 KB Output is correct
49 Correct 62 ms 135108 KB Output is correct
50 Correct 60 ms 135116 KB Output is correct
51 Correct 59 ms 135084 KB Output is correct
52 Correct 55 ms 135088 KB Output is correct
53 Correct 59 ms 135116 KB Output is correct
54 Correct 54 ms 135108 KB Output is correct
55 Correct 61 ms 135108 KB Output is correct
56 Correct 56 ms 135152 KB Output is correct
57 Correct 62 ms 135140 KB Output is correct
58 Correct 57 ms 135068 KB Output is correct
59 Correct 128 ms 135172 KB Output is correct
60 Correct 86 ms 135176 KB Output is correct
61 Correct 117 ms 135108 KB Output is correct
62 Correct 85 ms 135172 KB Output is correct
63 Correct 124 ms 135208 KB Output is correct
64 Correct 85 ms 135172 KB Output is correct
65 Correct 105 ms 135172 KB Output is correct
66 Correct 98 ms 135164 KB Output is correct
67 Correct 98 ms 135160 KB Output is correct
68 Correct 96 ms 135232 KB Output is correct
69 Correct 106 ms 135092 KB Output is correct
70 Correct 102 ms 135104 KB Output is correct
71 Correct 101 ms 135180 KB Output is correct
72 Correct 115 ms 135172 KB Output is correct
73 Correct 103 ms 135220 KB Output is correct
74 Correct 95 ms 135112 KB Output is correct
75 Correct 100 ms 135104 KB Output is correct
76 Correct 122 ms 135100 KB Output is correct
77 Correct 111 ms 135112 KB Output is correct
78 Correct 98 ms 135076 KB Output is correct
79 Correct 96 ms 135192 KB Output is correct
80 Correct 110 ms 135176 KB Output is correct
81 Correct 92 ms 135104 KB Output is correct
82 Correct 95 ms 135108 KB Output is correct
83 Correct 113 ms 135104 KB Output is correct
84 Correct 101 ms 135112 KB Output is correct
85 Correct 108 ms 135108 KB Output is correct
86 Correct 106 ms 135100 KB Output is correct
87 Correct 106 ms 135176 KB Output is correct
88 Correct 117 ms 135108 KB Output is correct
89 Correct 116 ms 135088 KB Output is correct
90 Correct 99 ms 135120 KB Output is correct
91 Correct 120 ms 135136 KB Output is correct
92 Correct 126 ms 135128 KB Output is correct
93 Correct 126 ms 135180 KB Output is correct