답안 #534226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534226 2022-03-08T02:36:50 Z Haruto810198 Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
125 ms 133924 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())

#define vi vector<int>
#define pii pair<int, int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF = INT_MAX;
const int LNF = INF*INF;
const int MOD = 1000000007;
const double eps = 1e-12;

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")

const int MAX = 210;

int n, L;
int pos[MAX];
int lim[MAX];
int dp[MAX][MAX][MAX][2];

// dp[l][r][c][p] : min. time of visited l from left, r from right, collected c, now at l/r

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin>>n>>L;
	FOR(i, 1, n, 1){
		cin>>pos[i];
	}
	pos[n+1] = L;

	FOR(i, 1, n, 1){
		cin>>lim[i];
	}
	
	FOR(l, 0, n, 1){
		FOR(r, 0, n, 1){
			FOR(c, 0, n, 1){
				FOR(p, 0, 1, 1){
					dp[l][r][c][p] = LNF;
				}
			}
		}
	}
	dp[0][0][0][0] = dp[0][0][0][1] = 0;
	
	FOR(l, 0, n, 1){
		FOR(r, 0, n, 1){
			
			if(l + r >= n) break;

			FOR(c, 0, n, 1){
				// dp[l][r][c][0] -> dp[l+1][r][?][0], dp[l][r+1][?][1]
				int tol = dp[l][r][c][0] + (pos[l+1] - pos[l]);
				int tor = dp[l][r][c][0] + (pos[l] + L - pos[n-r]);
				int cl = c + (tol <= lim[l+1]);
				int cr = c + (tor <= lim[n-r]);
				dp[l+1][r][cl][0] = min(dp[l+1][r][cl][0], tol);
				dp[l][r+1][cr][1] = min(dp[l][r+1][cr][1], tor);

				// dp[l][r][c][1] -> dp[l+1][r][?][0], dp[l][r+1][?][1]
				tol = dp[l][r][c][1] + (L - pos[n-r+1] + pos[l+1]);
				tor = dp[l][r][c][1] + (pos[n-r+1] - pos[n-r]);
				cl = c + (tol <= lim[l+1]);
				cr = c + (tor <= lim[n-r]);
				dp[l+1][r][cl][0] = min(dp[l+1][r][cl][0], tol);
				dp[l][r+1][cr][1] = min(dp[l][r+1][cr][1], tor);
			}
		}
	}
	
	int res = 0;
	FOR(l, 0, n, 1){
		FOR(r, 0, n, 1){
			FOR(c, 0, n, 1){
				FOR(p, 0, 1, 1){
					if(dp[l][r][c][p] < LNF) res = max(res, c);
				}
			}
		}
	}

	cout<<res<<'\n';

	return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 672 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 584 KB Output is correct
16 Correct 1 ms 836 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 672 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 584 KB Output is correct
16 Correct 1 ms 836 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 1 ms 844 KB Output is correct
21 Correct 1 ms 1088 KB Output is correct
22 Correct 1 ms 588 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Correct 1 ms 972 KB Output is correct
25 Correct 1 ms 972 KB Output is correct
26 Correct 1 ms 972 KB Output is correct
27 Correct 1 ms 580 KB Output is correct
28 Correct 1 ms 580 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Correct 1 ms 1100 KB Output is correct
31 Correct 1 ms 1092 KB Output is correct
32 Correct 1 ms 964 KB Output is correct
33 Correct 1 ms 1100 KB Output is correct
34 Correct 1 ms 1100 KB Output is correct
35 Correct 1 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 672 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 584 KB Output is correct
16 Correct 1 ms 836 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
18 Correct 86 ms 107484 KB Output is correct
19 Correct 51 ms 65144 KB Output is correct
20 Correct 31 ms 34744 KB Output is correct
21 Correct 46 ms 61552 KB Output is correct
22 Correct 60 ms 79792 KB Output is correct
23 Correct 19 ms 29516 KB Output is correct
24 Correct 20 ms 23116 KB Output is correct
25 Correct 21 ms 29024 KB Output is correct
26 Correct 8 ms 11072 KB Output is correct
27 Correct 27 ms 30156 KB Output is correct
28 Correct 15 ms 21460 KB Output is correct
29 Correct 20 ms 30796 KB Output is correct
30 Correct 17 ms 24316 KB Output is correct
31 Correct 20 ms 29028 KB Output is correct
32 Correct 10 ms 15160 KB Output is correct
33 Correct 18 ms 29028 KB Output is correct
34 Correct 6 ms 10316 KB Output is correct
35 Correct 20 ms 28408 KB Output is correct
36 Correct 8 ms 13516 KB Output is correct
37 Correct 19 ms 30204 KB Output is correct
38 Correct 11 ms 16564 KB Output is correct
39 Correct 22 ms 31536 KB Output is correct
40 Correct 12 ms 18432 KB Output is correct
41 Correct 112 ms 132464 KB Output is correct
42 Correct 80 ms 89316 KB Output is correct
43 Correct 121 ms 132548 KB Output is correct
44 Correct 73 ms 88132 KB Output is correct
45 Correct 110 ms 132584 KB Output is correct
46 Correct 68 ms 89312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 672 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 584 KB Output is correct
16 Correct 1 ms 836 KB Output is correct
17 Correct 1 ms 844 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 716 KB Output is correct
20 Correct 1 ms 844 KB Output is correct
21 Correct 1 ms 1088 KB Output is correct
22 Correct 1 ms 588 KB Output is correct
23 Correct 1 ms 1100 KB Output is correct
24 Correct 1 ms 972 KB Output is correct
25 Correct 1 ms 972 KB Output is correct
26 Correct 1 ms 972 KB Output is correct
27 Correct 1 ms 580 KB Output is correct
28 Correct 1 ms 580 KB Output is correct
29 Correct 1 ms 1100 KB Output is correct
30 Correct 1 ms 1100 KB Output is correct
31 Correct 1 ms 1092 KB Output is correct
32 Correct 1 ms 964 KB Output is correct
33 Correct 1 ms 1100 KB Output is correct
34 Correct 1 ms 1100 KB Output is correct
35 Correct 1 ms 1100 KB Output is correct
36 Correct 86 ms 107484 KB Output is correct
37 Correct 51 ms 65144 KB Output is correct
38 Correct 31 ms 34744 KB Output is correct
39 Correct 46 ms 61552 KB Output is correct
40 Correct 60 ms 79792 KB Output is correct
41 Correct 19 ms 29516 KB Output is correct
42 Correct 20 ms 23116 KB Output is correct
43 Correct 21 ms 29024 KB Output is correct
44 Correct 8 ms 11072 KB Output is correct
45 Correct 27 ms 30156 KB Output is correct
46 Correct 15 ms 21460 KB Output is correct
47 Correct 20 ms 30796 KB Output is correct
48 Correct 17 ms 24316 KB Output is correct
49 Correct 20 ms 29028 KB Output is correct
50 Correct 10 ms 15160 KB Output is correct
51 Correct 18 ms 29028 KB Output is correct
52 Correct 6 ms 10316 KB Output is correct
53 Correct 20 ms 28408 KB Output is correct
54 Correct 8 ms 13516 KB Output is correct
55 Correct 19 ms 30204 KB Output is correct
56 Correct 11 ms 16564 KB Output is correct
57 Correct 22 ms 31536 KB Output is correct
58 Correct 12 ms 18432 KB Output is correct
59 Correct 112 ms 132464 KB Output is correct
60 Correct 80 ms 89316 KB Output is correct
61 Correct 121 ms 132548 KB Output is correct
62 Correct 73 ms 88132 KB Output is correct
63 Correct 110 ms 132584 KB Output is correct
64 Correct 68 ms 89312 KB Output is correct
65 Correct 102 ms 119760 KB Output is correct
66 Correct 97 ms 109876 KB Output is correct
67 Correct 84 ms 105028 KB Output is correct
68 Correct 77 ms 97032 KB Output is correct
69 Correct 101 ms 118456 KB Output is correct
70 Correct 107 ms 113504 KB Output is correct
71 Correct 96 ms 114740 KB Output is correct
72 Correct 99 ms 115948 KB Output is correct
73 Correct 93 ms 107492 KB Output is correct
74 Correct 89 ms 100420 KB Output is correct
75 Correct 90 ms 111016 KB Output is correct
76 Correct 102 ms 127304 KB Output is correct
77 Correct 125 ms 127348 KB Output is correct
78 Correct 78 ms 98176 KB Output is correct
79 Correct 85 ms 101588 KB Output is correct
80 Correct 103 ms 124776 KB Output is correct
81 Correct 80 ms 102756 KB Output is correct
82 Correct 90 ms 108588 KB Output is correct
83 Correct 110 ms 132608 KB Output is correct
84 Correct 105 ms 113576 KB Output is correct
85 Correct 102 ms 123500 KB Output is correct
86 Correct 98 ms 120964 KB Output is correct
87 Correct 97 ms 111080 KB Output is correct
88 Correct 116 ms 133828 KB Output is correct
89 Correct 119 ms 133924 KB Output is correct
90 Correct 88 ms 112300 KB Output is correct
91 Correct 111 ms 133828 KB Output is correct
92 Correct 116 ms 133920 KB Output is correct
93 Correct 114 ms 131192 KB Output is correct