답안 #313375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
313375 2020-10-15T22:29:45 Z sofapuden Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
73 ms 133240 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 204;

ll n,l, X[maxn], T[maxn], dp[maxn][maxn][2][maxn];

int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	memset(dp, 0x3f, sizeof dp);	
	cin >> n >> l;
	for(int i = 1; i <= n; ++i)cin >> X[i];
	X[n+1] = l;
	for(int i = 1; i <= n; ++i)cin >> T[i];
	++n;
	T[0] = -1;
	T[n] = -1;
	dp[0][n][0][0] = 0;
	dp[0][n][1][0] = 0;
	
	int ans = 0;
	
	for(int i = 0; i <= n; ++i){
		for(int j = n; j >= i; --j){
			for(int k = 0; k <= n; ++k){
				if(i){
					dp[i][j][0][k] = min(dp[i][j][0][k], dp[i-1][j][0][k] + X[i] - X[i-1]);
				}
				if(j != n){
					dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j+1][1][k] + X[j+1] - X[j]);
				}
				if(k){
					if(i && dp[i-1][j][0][k-1] + X[i] - X[i-1] <= T[i]){
						dp[i][j][0][k] = min(dp[i][j][0][k], dp[i-1][j][0][k-1] + X[i] - X[i-1]);
					}
					if(j != n && dp[i][j+1][k-1][1] + X[j+1] - X[j] <= T[j]){
						dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j+1][1][k-1] + X[j+1] - X[j]);
					}
				}
				dp[i][j][0][k] = min(dp[i][j][0][k], dp[i][j][1][k] + l - X[j] + X[i]);
				dp[i][j][1][k] = min(dp[i][j][1][k], dp[i][j][0][k] + l - X[j] + X[i]);
				if(min(dp[i][j][0][k],dp[i][j][1][k]) < 1000000000ll)ans = max(ans,k);
			}
		}
	}
					
	
	cout << ans << "\n";
			
			
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 133240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 133240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 133240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 73 ms 133240 KB Output isn't correct
2 Halted 0 ms 0 KB -