Submission #661035

# Submission time Handle Problem Language Result Execution time Memory
661035 2022-11-24T00:56:41 Z GusterGoose27 Uplifting Excursion (BOI22_vault) C++11
0 / 100
585 ms 4452 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

typedef long long ll;

const int MAXN = 100;
const int MXVAL = 505000;
int n;
ll target;
int cnt[2*MAXN+1];
int mx_use[MXVAL+1];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> target;
	if (target > MXVAL) {
		cout << "impossible\n";
		return 0;
	}
	fill(mx_use, mx_use+MXVAL+1, -1);
	mx_use[0] = 0;
	for (int i = 0; i <= 2*n; i++) cin >> cnt[i];
	for (int j = 1; j <= n; j++) {
		for (int i = MXVAL; i >= j; i--) {
			for (int p = 1; p <= cnt[n+j] && i-p*j >= 0; p++) 
				if (mx_use[i-p*j] >= 0) mx_use[i] = max(mx_use[i], mx_use[i-p*j]+p);
		}
	}
	for (int j = 1; j <= n; j++) {
		for (int i = target; i <= MXVAL-j; i++) {
			for (int p = 1; p <= cnt[n-j] && i+p*j <= MXVAL; p++)
				if (mx_use[i+p*j] >= 0) mx_use[i] = max(mx_use[i], mx_use[i+p*j]+p);
		}
	}
	if (mx_use[target] == -1) {
		cout << "impossible\n";
		return 0;
	}
	cout << (mx_use[target]+cnt[n]) << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2260 KB Output is correct
2 Correct 6 ms 2260 KB Output is correct
3 Correct 7 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Runtime error 585 ms 4452 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2260 KB Output is correct
2 Correct 6 ms 2260 KB Output is correct
3 Correct 7 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Runtime error 585 ms 4452 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2260 KB Output is correct
2 Correct 6 ms 2260 KB Output is correct
3 Correct 7 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Runtime error 585 ms 4452 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2260 KB Output is correct
2 Correct 6 ms 2260 KB Output is correct
3 Correct 7 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Runtime error 585 ms 4452 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2260 KB Output is correct
2 Correct 6 ms 2260 KB Output is correct
3 Correct 7 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Runtime error 585 ms 4452 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -