답안 #829345

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829345 2023-08-18T09:35:25 Z QwertyPi Uplifting Excursion (BOI22_vault) C++14
0 / 100
9 ms 23732 KB
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#define int long long

using namespace std;

const int M = 300 + 11;
const int X = M * M;
const int INF = 1LL << 60;
int a[M * 2];
int s[M * 2];
int dp[M * 2][X];

int norm(int x, int m){
	if(x >= 0) return x;
	return (x % m + m) % m;
}

int32_t main(){
	int m, L; cin >> m >> L;
	for(int i = 0; i <= m * 2; i++) cin >> a[i];
	
	int ans = a[m];
	for(int i = m + 1; i <= m * 2; i++) s[i] = min(L, s[i - 1] + (i - m) * a[i]);

	for(int i = m; i <= m * 2; i++)
		fill(dp[i], dp[i] + X, -INF);

	dp[m][0] = 0;
	for(int i = m + 1; i <= m * 2; i++){
		for(int j = 0; j <= m * (i - 1 - m); j++){
			int left = norm(s[i] - s[i - 1] + j - a[i] * (i - m), i - m);
			int right = m * (i - m);
			int inc = i - m;
			int delta = ((s[i] - left) - (s[i - 1] - j)) / (i - m);
			for(int k = left; k <= right; k += inc){
				dp[i][k] = max(dp[i][k], dp[i - 1][j] + delta);
				delta--;
			}
		}
	}

	if(s[m * 2] < L || L < 0){
		cout << "impossible" << endl;
		return 0;
	}
	if(dp[m * 2][0] < 0){
		cout << "impossible" << endl;
	}else{
		cout << ans + dp[m * 2][0] << endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8532 KB Output is correct
2 Correct 9 ms 23676 KB Output is correct
3 Incorrect 8 ms 23732 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8532 KB Output is correct
2 Correct 9 ms 23676 KB Output is correct
3 Incorrect 8 ms 23732 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8532 KB Output is correct
2 Correct 9 ms 23676 KB Output is correct
3 Incorrect 8 ms 23732 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8532 KB Output is correct
2 Correct 9 ms 23676 KB Output is correct
3 Incorrect 8 ms 23732 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8532 KB Output is correct
2 Correct 9 ms 23676 KB Output is correct
3 Incorrect 8 ms 23732 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2516 KB Output isn't correct
2 Halted 0 ms 0 KB -