답안 #1032600

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032600 2024-07-24T03:39:09 Z juicy Collecting Stamps 3 (JOI20_ho_t3) C++17
5 / 100
62 ms 53308 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int N = 205, inf = 1e9 + 7;
 
int n, l;
int x[N], t[N], dp[N][N][N][2];
 
int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
 
	cin >> n >> l;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> t[i];
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n + 1; ++j) {
			for (int k = 0; k <= n; ++k) {
				for (int x = 0; x < 2; ++x) {
					dp[i][j][k][x] = inf;
				}
			}
		}
	}
	dp[0][n + 1][0][0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = n + 1; j > i + 1; --j) {
			for (int cnt = 0; cnt <= n; ++cnt) {
				if (dp[i][j][cnt][0] != inf) {
					int c = dp[i][j][cnt][0] + x[i + 1] - x[i];
					int ncnt = cnt + (c <= t[i + 1]);
					dp[i + 1][j][ncnt][0] = min(dp[i + 1][j][ncnt][0], c);
					c = dp[i][j][cnt][0] + x[i] + l - x[j - 1];
					ncnt = cnt + (c <= t[j - 1]);
					dp[i][j - 1][ncnt][1] = min(dp[i][j - 1][ncnt][0], c);
				} 
				if (dp[i][j][cnt][1] != inf) {
					int c = dp[i][j][cnt][1] + l - x[j] + x[i + 1];
					int ncnt = cnt + (c <= t[i + 1]);
					dp[i + 1][j][ncnt][0] = min(dp[i + 1][j][ncnt][1], c);
					c = dp[i][j][cnt][1] + x[j] - x[j - 1];
					ncnt = cnt + (c <= t[j - 1]);
					dp[i][j - 1][ncnt][1] = min(dp[i][j - 1][ncnt][1], c);
				}
			}
		}
	}
	int res = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n + 1; ++j) {
			for (int k = 0; k <= n; ++k) {
				for (int x = 0; x < 2; ++x) {
					if (dp[i][j][k][x] < inf) {
						res = max(res, k);
					}
				}
			}
		}
	}
	cout << res;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Incorrect 0 ms 860 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Incorrect 62 ms 53308 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Incorrect 0 ms 860 KB Output isn't correct
19 Halted 0 ms 0 KB -