답안 #661037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
661037 2022-11-24T01:02:26 Z GusterGoose27 Uplifting Excursion (BOI22_vault) C++11
5 / 100
5000 ms 2300 KB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#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 (abs(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];
	if (target < 0) {
		target *= -1;
		for (int i = 0; i < n; i++) swap(cnt[i], cnt[2*n-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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2260 KB Output is correct
2 Correct 6 ms 2292 KB Output is correct
3 Correct 4 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1419 ms 2276 KB Output is correct
7 Correct 540 ms 2272 KB Output is correct
8 Correct 1292 ms 2272 KB Output is correct
9 Correct 2298 ms 2276 KB Output is correct
10 Correct 48 ms 2288 KB Output is correct
11 Correct 43 ms 2272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2260 KB Output is correct
2 Correct 6 ms 2292 KB Output is correct
3 Correct 4 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1419 ms 2276 KB Output is correct
7 Correct 540 ms 2272 KB Output is correct
8 Correct 1292 ms 2272 KB Output is correct
9 Correct 2298 ms 2276 KB Output is correct
10 Correct 48 ms 2288 KB Output is correct
11 Correct 43 ms 2272 KB Output is correct
12 Correct 11 ms 2260 KB Output is correct
13 Correct 5 ms 2300 KB Output is correct
14 Correct 4 ms 2260 KB Output is correct
15 Correct 27 ms 2296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1412 ms 2276 KB Output is correct
18 Correct 524 ms 2288 KB Output is correct
19 Correct 1274 ms 2260 KB Output is correct
20 Correct 2286 ms 2276 KB Output is correct
21 Correct 49 ms 2260 KB Output is correct
22 Correct 44 ms 2260 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Execution timed out 5073 ms 2260 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2260 KB Output is correct
2 Correct 6 ms 2292 KB Output is correct
3 Correct 4 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1419 ms 2276 KB Output is correct
7 Correct 540 ms 2272 KB Output is correct
8 Correct 1292 ms 2272 KB Output is correct
9 Correct 2298 ms 2276 KB Output is correct
10 Correct 48 ms 2288 KB Output is correct
11 Correct 43 ms 2272 KB Output is correct
12 Correct 27 ms 2260 KB Output is correct
13 Incorrect 0 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2260 KB Output is correct
2 Correct 6 ms 2292 KB Output is correct
3 Correct 4 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1419 ms 2276 KB Output is correct
7 Correct 540 ms 2272 KB Output is correct
8 Correct 1292 ms 2272 KB Output is correct
9 Correct 2298 ms 2276 KB Output is correct
10 Correct 48 ms 2288 KB Output is correct
11 Correct 43 ms 2272 KB Output is correct
12 Correct 11 ms 2260 KB Output is correct
13 Correct 5 ms 2300 KB Output is correct
14 Correct 4 ms 2260 KB Output is correct
15 Correct 27 ms 2296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1412 ms 2276 KB Output is correct
18 Correct 524 ms 2288 KB Output is correct
19 Correct 1274 ms 2260 KB Output is correct
20 Correct 2286 ms 2276 KB Output is correct
21 Correct 49 ms 2260 KB Output is correct
22 Correct 44 ms 2260 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Execution timed out 5073 ms 2260 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 2260 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2260 KB Output is correct
2 Correct 6 ms 2292 KB Output is correct
3 Correct 4 ms 2260 KB Output is correct
4 Correct 30 ms 2260 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1419 ms 2276 KB Output is correct
7 Correct 540 ms 2272 KB Output is correct
8 Correct 1292 ms 2272 KB Output is correct
9 Correct 2298 ms 2276 KB Output is correct
10 Correct 48 ms 2288 KB Output is correct
11 Correct 43 ms 2272 KB Output is correct
12 Correct 11 ms 2260 KB Output is correct
13 Correct 5 ms 2300 KB Output is correct
14 Correct 4 ms 2260 KB Output is correct
15 Correct 27 ms 2296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1412 ms 2276 KB Output is correct
18 Correct 524 ms 2288 KB Output is correct
19 Correct 1274 ms 2260 KB Output is correct
20 Correct 2286 ms 2276 KB Output is correct
21 Correct 49 ms 2260 KB Output is correct
22 Correct 44 ms 2260 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Execution timed out 5073 ms 2260 KB Time limit exceeded
25 Halted 0 ms 0 KB -