Submission #792061

# Submission time Handle Problem Language Result Execution time Memory
792061 2023-07-24T14:39:38 Z ToniB Uplifting Excursion (BOI22_vault) C++17
0 / 100
320 ms 401088 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
const int K = MAXN * MAXN / 4;

int m, L, a[MAXN];
int dp[MAXN][MAXN * MAXN / 2];

int main(){
	cin >> m >> L;
	for(int i = 0; i < 2 * m + 1; ++i) cin >> a[i];
	for(int i = 0; i < 2 * m + 1; ++i){
		// dp[i][j] = max{dp[i - 1][j - x * (i - m)] + x}
		for(int j = 0; j < MAXN * MAXN / 2; ++j){
			dp[i][j] = -1e9;
			for(int x = 0; x <= a[i]; ++x){
				if(j - x * (i - m) >= 0 && j - x * (i - m) < MAXN * MAXN / 2){
					if(i) dp[i][j] = max(dp[i][j], dp[i - 1][j - x * (i - m)] + x);
					else if(j - x * (i - m) == K) dp[i][j] = max(dp[i][j], x);
				}
			}
		}
	}
	if(L + K < 0 || L + K >= MAXN * MAXN / 2) cout << "impossible\n";
	if(dp[2 * m][L + K] < 0) cout << "impossible\n";
	else cout << dp[2 * m][L + K];
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 10068 KB Output is correct
2 Correct 14 ms 13892 KB Output is correct
3 Correct 8 ms 6160 KB Output is correct
4 Correct 85 ms 41364 KB Output is correct
5 Runtime error 320 ms 401088 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 10068 KB Output is correct
2 Correct 14 ms 13892 KB Output is correct
3 Correct 8 ms 6160 KB Output is correct
4 Correct 85 ms 41364 KB Output is correct
5 Runtime error 320 ms 401088 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 41396 KB Output is correct
2 Runtime error 198 ms 242284 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 41396 KB Output is correct
2 Runtime error 198 ms 242284 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 41396 KB Output is correct
2 Runtime error 198 ms 242284 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 10068 KB Output is correct
2 Correct 14 ms 13892 KB Output is correct
3 Correct 8 ms 6160 KB Output is correct
4 Correct 85 ms 41364 KB Output is correct
5 Runtime error 320 ms 401088 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 41396 KB Output is correct
2 Runtime error 198 ms 242284 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 10068 KB Output is correct
2 Correct 14 ms 13892 KB Output is correct
3 Correct 8 ms 6160 KB Output is correct
4 Correct 85 ms 41364 KB Output is correct
5 Runtime error 320 ms 401088 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 41396 KB Output is correct
2 Runtime error 198 ms 242284 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 10068 KB Output is correct
2 Correct 14 ms 13892 KB Output is correct
3 Correct 8 ms 6160 KB Output is correct
4 Correct 85 ms 41364 KB Output is correct
5 Runtime error 320 ms 401088 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -