답안 #574290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574290 2022-06-08T09:42:58 Z 8e7 Uplifting Excursion (BOI22_vault) C++17
30 / 100
1107 ms 17876 KB
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 1100005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
const int inf = 1<<30;
int dp[2][maxn];
int main() {
	io
		int m;
	ll L;
	cin >> m >> L;
	vector<ll> a(2*m+1), ex(2*m+1);	
	ll mins = 0, ans = 0;
	for (int i = 0;i < 2*m+1;i++) {
		cin >> a[i];
		if (i == m) ans += a[i], a[i] = 0;
	}
	for (int i = m+1;i < 2*m+1;i++) {
		ll p = min(a[i], L / (i-m));
		ans += p;
		L -= p * (i-m);
		a[i] -= p;

		ex[i] = min(a[i], (ll)2*m);
		ex[2 * m - i] = min(p,(ll)2 * m);
	}
	for (int i = 0;i < 2 * m+1;i++) {
		if (i < m) mins += ex[i] * (i - m);
	}
	for (int i = 0;i < maxn;i++) dp[0][i] = dp[1][i] = -inf;	

	dp[0][-mins] = 0;
	dp[1][-mins] = 0;
	for (int i = 0;i < 2*m+1;i++) {
		ll cnt = 1;
		vector<int> num;
		while (ex[i] >= cnt) {
			num.push_back(cnt);
			ex[i] -= cnt;
			cnt <<= 1;
		}
		if (ex[i] > 0) num.push_back(ex[i]);
		for (int p:num) {
			for (int j = 0;j < maxn;j++) {
				int val = j + p * (i-m);
				int del = i < m ? -p : p;
				if (val >= 0 && val < maxn) dp[1][val] = max(dp[1][val], dp[0][j] + del);
			}
			for (int j = 0;j < maxn;j++) dp[0][j] = dp[1][j];
		}
	}
	if (L - mins >= maxn || L - mins < 0 || dp[0][L - mins] < -maxn) cout << "impossible\n";
	else cout << dp[0][L - mins]+ans << "\n";
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 8916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 8916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 8916 KB Output is correct
2 Correct 237 ms 8916 KB Output is correct
3 Correct 73 ms 9036 KB Output is correct
4 Correct 240 ms 8916 KB Output is correct
5 Correct 264 ms 8912 KB Output is correct
6 Correct 209 ms 8920 KB Output is correct
7 Correct 33 ms 8916 KB Output is correct
8 Correct 34 ms 8924 KB Output is correct
9 Correct 122 ms 8924 KB Output is correct
10 Correct 156 ms 8912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 8916 KB Output is correct
2 Correct 237 ms 8916 KB Output is correct
3 Correct 73 ms 9036 KB Output is correct
4 Correct 240 ms 8916 KB Output is correct
5 Correct 264 ms 8912 KB Output is correct
6 Correct 209 ms 8920 KB Output is correct
7 Correct 33 ms 8916 KB Output is correct
8 Correct 34 ms 8924 KB Output is correct
9 Correct 122 ms 8924 KB Output is correct
10 Correct 156 ms 8912 KB Output is correct
11 Incorrect 11 ms 8916 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 8916 KB Output is correct
2 Correct 237 ms 8916 KB Output is correct
3 Correct 73 ms 9036 KB Output is correct
4 Correct 240 ms 8916 KB Output is correct
5 Correct 264 ms 8912 KB Output is correct
6 Correct 209 ms 8920 KB Output is correct
7 Correct 33 ms 8916 KB Output is correct
8 Correct 34 ms 8924 KB Output is correct
9 Correct 122 ms 8924 KB Output is correct
10 Correct 156 ms 8912 KB Output is correct
11 Correct 45 ms 8916 KB Output is correct
12 Correct 230 ms 8916 KB Output is correct
13 Correct 68 ms 8916 KB Output is correct
14 Correct 252 ms 8916 KB Output is correct
15 Correct 248 ms 8916 KB Output is correct
16 Correct 208 ms 8916 KB Output is correct
17 Correct 32 ms 8916 KB Output is correct
18 Correct 34 ms 8916 KB Output is correct
19 Correct 116 ms 8920 KB Output is correct
20 Correct 158 ms 8916 KB Output is correct
21 Correct 25 ms 8916 KB Output is correct
22 Correct 36 ms 8916 KB Output is correct
23 Correct 420 ms 8916 KB Output is correct
24 Correct 188 ms 8916 KB Output is correct
25 Correct 402 ms 8916 KB Output is correct
26 Correct 476 ms 8916 KB Output is correct
27 Correct 463 ms 8912 KB Output is correct
28 Correct 328 ms 8916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 8916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 8916 KB Output is correct
2 Correct 237 ms 8916 KB Output is correct
3 Correct 73 ms 9036 KB Output is correct
4 Correct 240 ms 8916 KB Output is correct
5 Correct 264 ms 8912 KB Output is correct
6 Correct 209 ms 8920 KB Output is correct
7 Correct 33 ms 8916 KB Output is correct
8 Correct 34 ms 8924 KB Output is correct
9 Correct 122 ms 8924 KB Output is correct
10 Correct 156 ms 8912 KB Output is correct
11 Correct 45 ms 8916 KB Output is correct
12 Correct 230 ms 8916 KB Output is correct
13 Correct 68 ms 8916 KB Output is correct
14 Correct 252 ms 8916 KB Output is correct
15 Correct 248 ms 8916 KB Output is correct
16 Correct 208 ms 8916 KB Output is correct
17 Correct 32 ms 8916 KB Output is correct
18 Correct 34 ms 8916 KB Output is correct
19 Correct 116 ms 8920 KB Output is correct
20 Correct 158 ms 8916 KB Output is correct
21 Correct 25 ms 8916 KB Output is correct
22 Correct 36 ms 8916 KB Output is correct
23 Correct 420 ms 8916 KB Output is correct
24 Correct 188 ms 8916 KB Output is correct
25 Correct 402 ms 8916 KB Output is correct
26 Correct 476 ms 8916 KB Output is correct
27 Correct 463 ms 8912 KB Output is correct
28 Correct 328 ms 8916 KB Output is correct
29 Correct 46 ms 8916 KB Output is correct
30 Correct 237 ms 8916 KB Output is correct
31 Correct 69 ms 8916 KB Output is correct
32 Correct 247 ms 8916 KB Output is correct
33 Correct 244 ms 8940 KB Output is correct
34 Correct 208 ms 8916 KB Output is correct
35 Correct 30 ms 8916 KB Output is correct
36 Correct 33 ms 8916 KB Output is correct
37 Correct 120 ms 8916 KB Output is correct
38 Correct 166 ms 8916 KB Output is correct
39 Correct 24 ms 8936 KB Output is correct
40 Correct 35 ms 8916 KB Output is correct
41 Correct 424 ms 8916 KB Output is correct
42 Correct 198 ms 8916 KB Output is correct
43 Correct 411 ms 8916 KB Output is correct
44 Correct 481 ms 8928 KB Output is correct
45 Correct 446 ms 9036 KB Output is correct
46 Correct 331 ms 8916 KB Output is correct
47 Correct 30 ms 8916 KB Output is correct
48 Correct 40 ms 8916 KB Output is correct
49 Correct 928 ms 8916 KB Output is correct
50 Correct 425 ms 8916 KB Output is correct
51 Correct 985 ms 9040 KB Output is correct
52 Correct 1107 ms 8916 KB Output is correct
53 Correct 972 ms 8924 KB Output is correct
54 Correct 804 ms 8916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 8916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 8916 KB Output is correct
2 Correct 237 ms 8916 KB Output is correct
3 Correct 73 ms 9036 KB Output is correct
4 Correct 240 ms 8916 KB Output is correct
5 Correct 264 ms 8912 KB Output is correct
6 Correct 209 ms 8920 KB Output is correct
7 Correct 33 ms 8916 KB Output is correct
8 Correct 34 ms 8924 KB Output is correct
9 Correct 122 ms 8924 KB Output is correct
10 Correct 156 ms 8912 KB Output is correct
11 Correct 45 ms 8916 KB Output is correct
12 Correct 230 ms 8916 KB Output is correct
13 Correct 68 ms 8916 KB Output is correct
14 Correct 252 ms 8916 KB Output is correct
15 Correct 248 ms 8916 KB Output is correct
16 Correct 208 ms 8916 KB Output is correct
17 Correct 32 ms 8916 KB Output is correct
18 Correct 34 ms 8916 KB Output is correct
19 Correct 116 ms 8920 KB Output is correct
20 Correct 158 ms 8916 KB Output is correct
21 Correct 25 ms 8916 KB Output is correct
22 Correct 36 ms 8916 KB Output is correct
23 Correct 420 ms 8916 KB Output is correct
24 Correct 188 ms 8916 KB Output is correct
25 Correct 402 ms 8916 KB Output is correct
26 Correct 476 ms 8916 KB Output is correct
27 Correct 463 ms 8912 KB Output is correct
28 Correct 328 ms 8916 KB Output is correct
29 Correct 46 ms 8916 KB Output is correct
30 Correct 237 ms 8916 KB Output is correct
31 Correct 69 ms 8916 KB Output is correct
32 Correct 247 ms 8916 KB Output is correct
33 Correct 244 ms 8940 KB Output is correct
34 Correct 208 ms 8916 KB Output is correct
35 Correct 30 ms 8916 KB Output is correct
36 Correct 33 ms 8916 KB Output is correct
37 Correct 120 ms 8916 KB Output is correct
38 Correct 166 ms 8916 KB Output is correct
39 Correct 24 ms 8936 KB Output is correct
40 Correct 35 ms 8916 KB Output is correct
41 Correct 424 ms 8916 KB Output is correct
42 Correct 198 ms 8916 KB Output is correct
43 Correct 411 ms 8916 KB Output is correct
44 Correct 481 ms 8928 KB Output is correct
45 Correct 446 ms 9036 KB Output is correct
46 Correct 331 ms 8916 KB Output is correct
47 Correct 30 ms 8916 KB Output is correct
48 Correct 40 ms 8916 KB Output is correct
49 Correct 928 ms 8916 KB Output is correct
50 Correct 425 ms 8916 KB Output is correct
51 Correct 985 ms 9040 KB Output is correct
52 Correct 1107 ms 8916 KB Output is correct
53 Correct 972 ms 8924 KB Output is correct
54 Correct 804 ms 8916 KB Output is correct
55 Correct 49 ms 8908 KB Output is correct
56 Correct 250 ms 8916 KB Output is correct
57 Correct 68 ms 8916 KB Output is correct
58 Correct 252 ms 8916 KB Output is correct
59 Correct 275 ms 8916 KB Output is correct
60 Correct 212 ms 8916 KB Output is correct
61 Correct 31 ms 8932 KB Output is correct
62 Correct 34 ms 8916 KB Output is correct
63 Correct 116 ms 8916 KB Output is correct
64 Correct 169 ms 9036 KB Output is correct
65 Correct 25 ms 8916 KB Output is correct
66 Correct 37 ms 8916 KB Output is correct
67 Correct 406 ms 8916 KB Output is correct
68 Correct 191 ms 8916 KB Output is correct
69 Correct 400 ms 8916 KB Output is correct
70 Correct 501 ms 8916 KB Output is correct
71 Correct 440 ms 8916 KB Output is correct
72 Correct 341 ms 8912 KB Output is correct
73 Correct 29 ms 8916 KB Output is correct
74 Correct 41 ms 8916 KB Output is correct
75 Correct 907 ms 8916 KB Output is correct
76 Correct 416 ms 8916 KB Output is correct
77 Correct 992 ms 8916 KB Output is correct
78 Correct 1096 ms 8920 KB Output is correct
79 Correct 934 ms 8916 KB Output is correct
80 Correct 798 ms 8916 KB Output is correct
81 Runtime error 12 ms 17876 KB Execution killed with signal 11
82 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 8916 KB Output isn't correct
2 Halted 0 ms 0 KB -