답안 #224039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224039 2020-04-17T05:46:34 Z shenxy Collecting Stamps 3 (JOI20_ho_t3) C++11
0 / 100
5 ms 768 KB
#include <cstdio>
#include <algorithm>
using namespace std;
const long long INF = 10000000001;
int N, L, X[202], T[202];
long long dist[202][202][201][2];
int main() {
	scanf("%d %d", &N, &L);
	for (int i = 1; i <= N; ++i) scanf("%d", &X[i]);
	for (int i = 1; i <= N; ++i) scanf("%d", &T[i]);
	X[0] = 0;
	X[N + 1] = L;
	for (int i = 0; i < N + 2; ++i) {
		for (int j = 0; j < N + 2; ++j) {
			for (int k = 0; k <= N; ++k) dist[i][j][k][0] = dist[i][j][k][1] = INF;
		}
	}
	dist[0][N + 1][0][0] = dist[0][N + 1][0][1] = 0;
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) {
			for (int k = N + 1; k > j; --k) {
				if (j != 0) dist[j][k][i][1] = min(dist[j][k][i][1], min(dist[j - 1][k][i][1] + X[j] - X[j - 1], dist[j - 1][k][i][0] + L - X[k] + X[j]));
				if (k != N + 1) dist[j][k][i][0] = min(dist[j][k][i][0], min(dist[j][k + 1][i][0] + X[k + 1] - X[k], dist[j][k + 1][i][1] + L - X[k] + X[j]));
				if (j != 0 && min(dist[j - 1][k][i - 1][1] + X[j] - X[j - 1], dist[j - 1][k][i - 1][0] + L - X[k] + X[j]) <= T[j]) dist[j][k][i][1] = min(dist[j][k][i][1], min(dist[j - 1][k][i - 1][1] + X[j] - X[j - 1], dist[j - 1][k][i - 1][0] + L - X[k] + X[j]));
				if (k != N + 1 && min(dist[j][k + 1][i - 1][0] + X[k + 1] - X[k], dist[j][k + 1][i - 1][1] + L - X[k] + X[j]) <= T[k]) dist[j][k][i][0] = min(dist[j][k][i][0], min(dist[j][k + 1][i - 1][0] + X[k + 1] - X[k], dist[j][k + 1][i - 1][1] + L - X[k] + X[j]));
				if (dist[j][k][i][0] < INF || dist[j][k][i][1] < INF) ans = max(ans, i);
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &L);
  ~~~~~^~~~~~~~~~~~~~~~~
ho_t3.cpp:9:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= N; ++i) scanf("%d", &X[i]);
                               ~~~~~^~~~~~~~~~~~~
ho_t3.cpp:10:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= N; ++i) scanf("%d", &T[i]);
                               ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 768 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 768 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 768 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 768 KB Output isn't correct
4 Halted 0 ms 0 KB -