Submission #1032584

# Submission time Handle Problem Language Result Execution time Memory
1032584 2024-07-24T03:17:15 Z juicy Collecting Stamps 3 (JOI20_ho_t3) C++17
5 / 100
43 ms 53340 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][1], 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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 728 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 0 ms 604 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 728 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 0 ms 604 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Incorrect 1 ms 860 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 728 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 0 ms 604 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Incorrect 43 ms 53340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 728 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 0 ms 604 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Incorrect 1 ms 860 KB Output isn't correct
19 Halted 0 ms 0 KB -