Submission #720674

# Submission time Handle Problem Language Result Execution time Memory
720674 2023-04-08T22:55:26 Z Juan Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
453 ms 132056 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e2 + 5, INF = 1e18;

int ans = 0, L, mx=0;
int dp[maxn][maxn][maxn][2];
int T[maxn], X[maxn];

int32_t main(){
	int n; cin >> n >> L;
	for(int i = 1; i <= n; i++) cin >> X[i];
	for(int i = 1; i <= n; i++) cin >> T[i], mx = max(mx, T[i]);
	for(int i = 0; i <= n+1; i++){
		for(int j = 0; j <= n+1; j++){
			for(int k = 0; k <= n+1; k++){
				dp[i][j][k][0] = dp[i][j][k][1] = INF;
			}
		}
	}

	priority_queue<tuple<int, int, int, int, int>> pq;
	pq.push({0, 0, n+1, 0, 0});
	dp[0][n+1][0][0] = 0;
	while(pq.size()){
		auto[t, l, r, s, d] = pq.top();
		pq.pop();
		ans = max(ans, s);
		if(l==r-1 || t>mx || t>dp[l][r][s][d]) continue;

		if(d==0){
			int t1 = X[l+1]-X[l];
			int add1 = (t1+t <= T[l+1]);
			int &m1 = dp[l+1][r][s+add1][d];

			int t2 = X[l]+(L-X[r-1]);
			int add2 = (t2+t <= T[r-1]);
			int &m2 = dp[l][r-1][s+add2][1-d];

			if(m1 > t+t1) m1= t+t1, pq.push({t+t1, l+1, r, s+add1, d});
			if(m2 > t+t2) m2= t+t2, pq.push({t+t2, l, r-1, s+add2, 1-d});
		}
		else{
			int t1 = X[r]-X[r-1];
			int add1 = (t1+t <= T[r-1]);
			int &m1 = dp[l][r-1][s+add1][d];

			int t2 = X[l+1]+(L-X[r]);
			int add2 = (t2+t <= T[l+1]);
			int &m2 = dp[l+1][r][s+add2][1-d];

			if(m1 > t+t1) m1= t+t1, pq.push({t+t1, l, r-1, s+add1, d});
			if(m2 > t+t2) m2= t+t2, pq.push({t+t2, l+1, r, s+add2, 1-d});
		}
	}

	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 0 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 0 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1072 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 692 KB Output is correct
29 Correct 1 ms 1236 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 980 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1236 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 0 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 75 ms 105992 KB Output is correct
19 Correct 44 ms 64572 KB Output is correct
20 Correct 20 ms 34644 KB Output is correct
21 Correct 40 ms 60984 KB Output is correct
22 Correct 51 ms 78940 KB Output is correct
23 Correct 23 ms 29552 KB Output is correct
24 Correct 13 ms 23092 KB Output is correct
25 Correct 24 ms 28932 KB Output is correct
26 Correct 5 ms 11188 KB Output is correct
27 Correct 24 ms 30168 KB Output is correct
28 Correct 9 ms 21480 KB Output is correct
29 Correct 23 ms 30676 KB Output is correct
30 Correct 11 ms 24260 KB Output is correct
31 Correct 25 ms 28952 KB Output is correct
32 Correct 9 ms 15316 KB Output is correct
33 Correct 32 ms 28852 KB Output is correct
34 Correct 5 ms 10452 KB Output is correct
35 Correct 21 ms 28344 KB Output is correct
36 Correct 5 ms 13524 KB Output is correct
37 Correct 21 ms 30068 KB Output is correct
38 Correct 8 ms 16596 KB Output is correct
39 Correct 23 ms 31316 KB Output is correct
40 Correct 9 ms 18576 KB Output is correct
41 Correct 71 ms 130712 KB Output is correct
42 Correct 37 ms 88232 KB Output is correct
43 Correct 75 ms 130756 KB Output is correct
44 Correct 34 ms 87120 KB Output is correct
45 Correct 71 ms 130740 KB Output is correct
46 Correct 35 ms 88264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 0 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 852 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1072 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 692 KB Output is correct
29 Correct 1 ms 1236 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 980 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1236 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
36 Correct 75 ms 105992 KB Output is correct
37 Correct 44 ms 64572 KB Output is correct
38 Correct 20 ms 34644 KB Output is correct
39 Correct 40 ms 60984 KB Output is correct
40 Correct 51 ms 78940 KB Output is correct
41 Correct 23 ms 29552 KB Output is correct
42 Correct 13 ms 23092 KB Output is correct
43 Correct 24 ms 28932 KB Output is correct
44 Correct 5 ms 11188 KB Output is correct
45 Correct 24 ms 30168 KB Output is correct
46 Correct 9 ms 21480 KB Output is correct
47 Correct 23 ms 30676 KB Output is correct
48 Correct 11 ms 24260 KB Output is correct
49 Correct 25 ms 28952 KB Output is correct
50 Correct 9 ms 15316 KB Output is correct
51 Correct 32 ms 28852 KB Output is correct
52 Correct 5 ms 10452 KB Output is correct
53 Correct 21 ms 28344 KB Output is correct
54 Correct 5 ms 13524 KB Output is correct
55 Correct 21 ms 30068 KB Output is correct
56 Correct 8 ms 16596 KB Output is correct
57 Correct 23 ms 31316 KB Output is correct
58 Correct 9 ms 18576 KB Output is correct
59 Correct 71 ms 130712 KB Output is correct
60 Correct 37 ms 88232 KB Output is correct
61 Correct 75 ms 130756 KB Output is correct
62 Correct 34 ms 87120 KB Output is correct
63 Correct 71 ms 130740 KB Output is correct
64 Correct 35 ms 88264 KB Output is correct
65 Correct 85 ms 118084 KB Output is correct
66 Correct 89 ms 108464 KB Output is correct
67 Correct 64 ms 103792 KB Output is correct
68 Correct 59 ms 95876 KB Output is correct
69 Correct 88 ms 116884 KB Output is correct
70 Correct 309 ms 112044 KB Output is correct
71 Correct 45 ms 113232 KB Output is correct
72 Correct 247 ms 114544 KB Output is correct
73 Correct 45 ms 106012 KB Output is correct
74 Correct 252 ms 99240 KB Output is correct
75 Correct 43 ms 109644 KB Output is correct
76 Correct 453 ms 125620 KB Output is correct
77 Correct 50 ms 125604 KB Output is correct
78 Correct 220 ms 96988 KB Output is correct
79 Correct 43 ms 100336 KB Output is correct
80 Correct 350 ms 123092 KB Output is correct
81 Correct 39 ms 101452 KB Output is correct
82 Correct 273 ms 107284 KB Output is correct
83 Correct 57 ms 130732 KB Output is correct
84 Correct 331 ms 111948 KB Output is correct
85 Correct 47 ms 121804 KB Output is correct
86 Correct 426 ms 119404 KB Output is correct
87 Correct 63 ms 109624 KB Output is correct
88 Correct 135 ms 132052 KB Output is correct
89 Correct 79 ms 131968 KB Output is correct
90 Correct 46 ms 110796 KB Output is correct
91 Correct 141 ms 132044 KB Output is correct
92 Correct 83 ms 132056 KB Output is correct
93 Correct 55 ms 129416 KB Output is correct