답안 #202302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
202302 2020-02-15T08:34:22 Z amoo_safar Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
145 ms 145528 KB
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const int N = 2e2 + 10;
const ll Inf = 1e15;
const int Mx = 1e9 + 1;

ll n, L;
ll x[N], t[N], dp[N][N][N][2];

ll Dis(ll i, ll j){
	return min(abs(i - j), L - abs(i - j));
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> L;
	for(int i = 0; i < n; i++)
		cin >> x[i];
	for(int i = 0; i < n; i++)
		cin >> t[i];
	ll ans = 0;
	memset(dp, 31, sizeof dp);
	dp[0][0][0][0] = 0;
	dp[0][0][0][1] = 0;
	ll T, I, J;
	for(int i = 0; i < n; i++){
		I = (i ? x[i - 1] : 0);
		for(int j = 0; i + j < n; j++){
			J = (j ? x[n - j] : 0);
			for(int k = 0; k <= i + j; k++){
				T = dp[i][j][k][0] + Dis(I, x[i]);
				dp[i + 1][j][k + (T <= t[i])][0] = min(dp[i + 1][j][k + (T <= t[i])][0], T);

				T = dp[i][j][k][0] + Dis(I, x[n - j - 1]);
				dp[i][j + 1][k + (T <= t[n - j - 1])][1] = min(dp[i][j + 1][k + (T <= t[n - j - 1])][1], T);
				
				T = dp[i][j][k][1] + Dis(J, x[i]);
				dp[i + 1][j][k + (T <= t[i])][0] = min(dp[i + 1][j][k + (T <= t[i])][0], T);
				
				T = dp[i][j][k][1] + Dis(J, x[n - j - 1]);
				dp[i][j + 1][k + (T <= t[n - j - 1])][1] = min(dp[i][j + 1][k + (T <= t[n - j - 1])][1], T);
			}
		}
	}
	for(int i = 0; i <= n; i++)
		for(int k = 0; k <= n; k++)
			if(min(dp[i][n - i][k][0], dp[i][n - i][k][1]) < Inf) ans = max(ans, (ll) k);
	cout << ans << '\n';
	return 0;
}
/*
10 87
9 23 33 38 42 44 45 62 67 78
15 91 7 27 31 53 12 91 89 4
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 145272 KB Output is correct
2 Correct 73 ms 145272 KB Output is correct
3 Correct 73 ms 145400 KB Output is correct
4 Correct 72 ms 145276 KB Output is correct
5 Correct 72 ms 145272 KB Output is correct
6 Correct 71 ms 145308 KB Output is correct
7 Correct 72 ms 145272 KB Output is correct
8 Correct 75 ms 145272 KB Output is correct
9 Correct 74 ms 145400 KB Output is correct
10 Correct 71 ms 145400 KB Output is correct
11 Correct 71 ms 145272 KB Output is correct
12 Correct 72 ms 145272 KB Output is correct
13 Correct 72 ms 145272 KB Output is correct
14 Correct 70 ms 145272 KB Output is correct
15 Correct 72 ms 145272 KB Output is correct
16 Correct 72 ms 145400 KB Output is correct
17 Correct 74 ms 145344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 145272 KB Output is correct
2 Correct 73 ms 145272 KB Output is correct
3 Correct 73 ms 145400 KB Output is correct
4 Correct 72 ms 145276 KB Output is correct
5 Correct 72 ms 145272 KB Output is correct
6 Correct 71 ms 145308 KB Output is correct
7 Correct 72 ms 145272 KB Output is correct
8 Correct 75 ms 145272 KB Output is correct
9 Correct 74 ms 145400 KB Output is correct
10 Correct 71 ms 145400 KB Output is correct
11 Correct 71 ms 145272 KB Output is correct
12 Correct 72 ms 145272 KB Output is correct
13 Correct 72 ms 145272 KB Output is correct
14 Correct 70 ms 145272 KB Output is correct
15 Correct 72 ms 145272 KB Output is correct
16 Correct 72 ms 145400 KB Output is correct
17 Correct 74 ms 145344 KB Output is correct
18 Correct 71 ms 145272 KB Output is correct
19 Correct 72 ms 145272 KB Output is correct
20 Correct 74 ms 145272 KB Output is correct
21 Correct 71 ms 145272 KB Output is correct
22 Correct 74 ms 145272 KB Output is correct
23 Correct 73 ms 145272 KB Output is correct
24 Correct 75 ms 145272 KB Output is correct
25 Correct 71 ms 145400 KB Output is correct
26 Correct 71 ms 145272 KB Output is correct
27 Correct 73 ms 145272 KB Output is correct
28 Correct 72 ms 145276 KB Output is correct
29 Correct 80 ms 145272 KB Output is correct
30 Correct 73 ms 145400 KB Output is correct
31 Correct 72 ms 145272 KB Output is correct
32 Correct 73 ms 145272 KB Output is correct
33 Correct 72 ms 145272 KB Output is correct
34 Correct 73 ms 145400 KB Output is correct
35 Correct 74 ms 145272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 145272 KB Output is correct
2 Correct 73 ms 145272 KB Output is correct
3 Correct 73 ms 145400 KB Output is correct
4 Correct 72 ms 145276 KB Output is correct
5 Correct 72 ms 145272 KB Output is correct
6 Correct 71 ms 145308 KB Output is correct
7 Correct 72 ms 145272 KB Output is correct
8 Correct 75 ms 145272 KB Output is correct
9 Correct 74 ms 145400 KB Output is correct
10 Correct 71 ms 145400 KB Output is correct
11 Correct 71 ms 145272 KB Output is correct
12 Correct 72 ms 145272 KB Output is correct
13 Correct 72 ms 145272 KB Output is correct
14 Correct 70 ms 145272 KB Output is correct
15 Correct 72 ms 145272 KB Output is correct
16 Correct 72 ms 145400 KB Output is correct
17 Correct 74 ms 145344 KB Output is correct
18 Correct 113 ms 145400 KB Output is correct
19 Correct 86 ms 145400 KB Output is correct
20 Correct 82 ms 145324 KB Output is correct
21 Correct 95 ms 145272 KB Output is correct
22 Correct 102 ms 145272 KB Output is correct
23 Correct 79 ms 145400 KB Output is correct
24 Correct 78 ms 145272 KB Output is correct
25 Correct 78 ms 145276 KB Output is correct
26 Correct 79 ms 145400 KB Output is correct
27 Correct 81 ms 145272 KB Output is correct
28 Correct 79 ms 145272 KB Output is correct
29 Correct 83 ms 145272 KB Output is correct
30 Correct 78 ms 145272 KB Output is correct
31 Correct 78 ms 145272 KB Output is correct
32 Correct 75 ms 145272 KB Output is correct
33 Correct 80 ms 145272 KB Output is correct
34 Correct 73 ms 145272 KB Output is correct
35 Correct 78 ms 145272 KB Output is correct
36 Correct 74 ms 145400 KB Output is correct
37 Correct 80 ms 145272 KB Output is correct
38 Correct 76 ms 145272 KB Output is correct
39 Correct 81 ms 145336 KB Output is correct
40 Correct 76 ms 145272 KB Output is correct
41 Correct 139 ms 145272 KB Output is correct
42 Correct 106 ms 145272 KB Output is correct
43 Correct 137 ms 145400 KB Output is correct
44 Correct 100 ms 145276 KB Output is correct
45 Correct 134 ms 145272 KB Output is correct
46 Correct 107 ms 145272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 145272 KB Output is correct
2 Correct 73 ms 145272 KB Output is correct
3 Correct 73 ms 145400 KB Output is correct
4 Correct 72 ms 145276 KB Output is correct
5 Correct 72 ms 145272 KB Output is correct
6 Correct 71 ms 145308 KB Output is correct
7 Correct 72 ms 145272 KB Output is correct
8 Correct 75 ms 145272 KB Output is correct
9 Correct 74 ms 145400 KB Output is correct
10 Correct 71 ms 145400 KB Output is correct
11 Correct 71 ms 145272 KB Output is correct
12 Correct 72 ms 145272 KB Output is correct
13 Correct 72 ms 145272 KB Output is correct
14 Correct 70 ms 145272 KB Output is correct
15 Correct 72 ms 145272 KB Output is correct
16 Correct 72 ms 145400 KB Output is correct
17 Correct 74 ms 145344 KB Output is correct
18 Correct 71 ms 145272 KB Output is correct
19 Correct 72 ms 145272 KB Output is correct
20 Correct 74 ms 145272 KB Output is correct
21 Correct 71 ms 145272 KB Output is correct
22 Correct 74 ms 145272 KB Output is correct
23 Correct 73 ms 145272 KB Output is correct
24 Correct 75 ms 145272 KB Output is correct
25 Correct 71 ms 145400 KB Output is correct
26 Correct 71 ms 145272 KB Output is correct
27 Correct 73 ms 145272 KB Output is correct
28 Correct 72 ms 145276 KB Output is correct
29 Correct 80 ms 145272 KB Output is correct
30 Correct 73 ms 145400 KB Output is correct
31 Correct 72 ms 145272 KB Output is correct
32 Correct 73 ms 145272 KB Output is correct
33 Correct 72 ms 145272 KB Output is correct
34 Correct 73 ms 145400 KB Output is correct
35 Correct 74 ms 145272 KB Output is correct
36 Correct 113 ms 145400 KB Output is correct
37 Correct 86 ms 145400 KB Output is correct
38 Correct 82 ms 145324 KB Output is correct
39 Correct 95 ms 145272 KB Output is correct
40 Correct 102 ms 145272 KB Output is correct
41 Correct 79 ms 145400 KB Output is correct
42 Correct 78 ms 145272 KB Output is correct
43 Correct 78 ms 145276 KB Output is correct
44 Correct 79 ms 145400 KB Output is correct
45 Correct 81 ms 145272 KB Output is correct
46 Correct 79 ms 145272 KB Output is correct
47 Correct 83 ms 145272 KB Output is correct
48 Correct 78 ms 145272 KB Output is correct
49 Correct 78 ms 145272 KB Output is correct
50 Correct 75 ms 145272 KB Output is correct
51 Correct 80 ms 145272 KB Output is correct
52 Correct 73 ms 145272 KB Output is correct
53 Correct 78 ms 145272 KB Output is correct
54 Correct 74 ms 145400 KB Output is correct
55 Correct 80 ms 145272 KB Output is correct
56 Correct 76 ms 145272 KB Output is correct
57 Correct 81 ms 145336 KB Output is correct
58 Correct 76 ms 145272 KB Output is correct
59 Correct 139 ms 145272 KB Output is correct
60 Correct 106 ms 145272 KB Output is correct
61 Correct 137 ms 145400 KB Output is correct
62 Correct 100 ms 145276 KB Output is correct
63 Correct 134 ms 145272 KB Output is correct
64 Correct 107 ms 145272 KB Output is correct
65 Correct 127 ms 145380 KB Output is correct
66 Correct 110 ms 145388 KB Output is correct
67 Correct 122 ms 145272 KB Output is correct
68 Correct 99 ms 145272 KB Output is correct
69 Correct 125 ms 145400 KB Output is correct
70 Correct 124 ms 145360 KB Output is correct
71 Correct 121 ms 145400 KB Output is correct
72 Correct 119 ms 145384 KB Output is correct
73 Correct 108 ms 145400 KB Output is correct
74 Correct 114 ms 145372 KB Output is correct
75 Correct 108 ms 145400 KB Output is correct
76 Correct 133 ms 145400 KB Output is correct
77 Correct 134 ms 145528 KB Output is correct
78 Correct 102 ms 145528 KB Output is correct
79 Correct 113 ms 145272 KB Output is correct
80 Correct 145 ms 145272 KB Output is correct
81 Correct 103 ms 145292 KB Output is correct
82 Correct 113 ms 145436 KB Output is correct
83 Correct 133 ms 145272 KB Output is correct
84 Correct 124 ms 145272 KB Output is correct
85 Correct 116 ms 145272 KB Output is correct
86 Correct 127 ms 145272 KB Output is correct
87 Correct 120 ms 145272 KB Output is correct
88 Correct 135 ms 145400 KB Output is correct
89 Correct 138 ms 145444 KB Output is correct
90 Correct 122 ms 145272 KB Output is correct
91 Correct 134 ms 145272 KB Output is correct
92 Correct 134 ms 145272 KB Output is correct
93 Correct 136 ms 145400 KB Output is correct