Submission #574296

# Submission time Handle Problem Language Result Execution time Memory
574296 2022-06-08T09:51:06 Z 8e7 Uplifting Excursion (BOI22_vault) C++17
30 / 100
4073 ms 48008 KB
//Challenge: Accepted
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
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 6000005
#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[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)m);
		ex[2 * m - i] = min(p,(ll)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[i] = -inf;	

	dp[-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) {
			if (i - m > 0) {
				for (int j = maxn - 1;j >= 0;j--) {
					int val = j + p * (i-m);
					if (val >= maxn) continue;
					int del = i < m ? -p : p;
					dp[val] = max(dp[val], dp[j] + del);
				}
			} else {
				for (int j = 0;j < maxn;j++) {
					int val = j + p * (i-m);
					if (val < 0) continue;
					int del = i < m ? -p : p;
					dp[val] = max(dp[val], dp[j] + del);
				}
			}
		}
	}
	if (L - mins >= maxn || L - mins < 0 || dp[L - mins] < -maxn) cout << "impossible\n";
	else cout << dp[L - mins]+ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 23780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 23780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 202 ms 23784 KB Output is correct
2 Correct 878 ms 23808 KB Output is correct
3 Correct 256 ms 23764 KB Output is correct
4 Correct 942 ms 23780 KB Output is correct
5 Correct 978 ms 23780 KB Output is correct
6 Correct 858 ms 23784 KB Output is correct
7 Correct 106 ms 23784 KB Output is correct
8 Correct 125 ms 23784 KB Output is correct
9 Correct 518 ms 23788 KB Output is correct
10 Correct 654 ms 23788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 202 ms 23784 KB Output is correct
2 Correct 878 ms 23808 KB Output is correct
3 Correct 256 ms 23764 KB Output is correct
4 Correct 942 ms 23780 KB Output is correct
5 Correct 978 ms 23780 KB Output is correct
6 Correct 858 ms 23784 KB Output is correct
7 Correct 106 ms 23784 KB Output is correct
8 Correct 125 ms 23784 KB Output is correct
9 Correct 518 ms 23788 KB Output is correct
10 Correct 654 ms 23788 KB Output is correct
11 Incorrect 45 ms 23764 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 202 ms 23784 KB Output is correct
2 Correct 878 ms 23808 KB Output is correct
3 Correct 256 ms 23764 KB Output is correct
4 Correct 942 ms 23780 KB Output is correct
5 Correct 978 ms 23780 KB Output is correct
6 Correct 858 ms 23784 KB Output is correct
7 Correct 106 ms 23784 KB Output is correct
8 Correct 125 ms 23784 KB Output is correct
9 Correct 518 ms 23788 KB Output is correct
10 Correct 654 ms 23788 KB Output is correct
11 Correct 200 ms 23784 KB Output is correct
12 Correct 915 ms 23788 KB Output is correct
13 Correct 257 ms 23688 KB Output is correct
14 Correct 914 ms 23784 KB Output is correct
15 Correct 1082 ms 23784 KB Output is correct
16 Correct 846 ms 23780 KB Output is correct
17 Correct 111 ms 23784 KB Output is correct
18 Correct 196 ms 23784 KB Output is correct
19 Correct 469 ms 23788 KB Output is correct
20 Correct 612 ms 23784 KB Output is correct
21 Correct 107 ms 23780 KB Output is correct
22 Correct 147 ms 23784 KB Output is correct
23 Correct 1671 ms 23780 KB Output is correct
24 Correct 741 ms 23788 KB Output is correct
25 Correct 1694 ms 23780 KB Output is correct
26 Correct 1925 ms 23788 KB Output is correct
27 Correct 1739 ms 23780 KB Output is correct
28 Correct 1372 ms 23788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 23780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 202 ms 23784 KB Output is correct
2 Correct 878 ms 23808 KB Output is correct
3 Correct 256 ms 23764 KB Output is correct
4 Correct 942 ms 23780 KB Output is correct
5 Correct 978 ms 23780 KB Output is correct
6 Correct 858 ms 23784 KB Output is correct
7 Correct 106 ms 23784 KB Output is correct
8 Correct 125 ms 23784 KB Output is correct
9 Correct 518 ms 23788 KB Output is correct
10 Correct 654 ms 23788 KB Output is correct
11 Correct 200 ms 23784 KB Output is correct
12 Correct 915 ms 23788 KB Output is correct
13 Correct 257 ms 23688 KB Output is correct
14 Correct 914 ms 23784 KB Output is correct
15 Correct 1082 ms 23784 KB Output is correct
16 Correct 846 ms 23780 KB Output is correct
17 Correct 111 ms 23784 KB Output is correct
18 Correct 196 ms 23784 KB Output is correct
19 Correct 469 ms 23788 KB Output is correct
20 Correct 612 ms 23784 KB Output is correct
21 Correct 107 ms 23780 KB Output is correct
22 Correct 147 ms 23784 KB Output is correct
23 Correct 1671 ms 23780 KB Output is correct
24 Correct 741 ms 23788 KB Output is correct
25 Correct 1694 ms 23780 KB Output is correct
26 Correct 1925 ms 23788 KB Output is correct
27 Correct 1739 ms 23780 KB Output is correct
28 Correct 1372 ms 23788 KB Output is correct
29 Correct 201 ms 23764 KB Output is correct
30 Correct 868 ms 23784 KB Output is correct
31 Correct 252 ms 23784 KB Output is correct
32 Correct 1124 ms 23784 KB Output is correct
33 Correct 885 ms 23800 KB Output is correct
34 Correct 823 ms 23784 KB Output is correct
35 Correct 96 ms 23788 KB Output is correct
36 Correct 112 ms 23780 KB Output is correct
37 Correct 425 ms 23780 KB Output is correct
38 Correct 590 ms 23788 KB Output is correct
39 Correct 96 ms 23764 KB Output is correct
40 Correct 132 ms 23764 KB Output is correct
41 Correct 1549 ms 23784 KB Output is correct
42 Correct 672 ms 23784 KB Output is correct
43 Correct 1486 ms 23784 KB Output is correct
44 Correct 1745 ms 23780 KB Output is correct
45 Correct 1623 ms 23796 KB Output is correct
46 Correct 1175 ms 23788 KB Output is correct
47 Correct 106 ms 23788 KB Output is correct
48 Correct 146 ms 23784 KB Output is correct
49 Correct 3447 ms 23792 KB Output is correct
50 Correct 1490 ms 23788 KB Output is correct
51 Correct 3627 ms 23788 KB Output is correct
52 Correct 4050 ms 23808 KB Output is correct
53 Correct 3534 ms 23788 KB Output is correct
54 Correct 2929 ms 23784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 23780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 202 ms 23784 KB Output is correct
2 Correct 878 ms 23808 KB Output is correct
3 Correct 256 ms 23764 KB Output is correct
4 Correct 942 ms 23780 KB Output is correct
5 Correct 978 ms 23780 KB Output is correct
6 Correct 858 ms 23784 KB Output is correct
7 Correct 106 ms 23784 KB Output is correct
8 Correct 125 ms 23784 KB Output is correct
9 Correct 518 ms 23788 KB Output is correct
10 Correct 654 ms 23788 KB Output is correct
11 Correct 200 ms 23784 KB Output is correct
12 Correct 915 ms 23788 KB Output is correct
13 Correct 257 ms 23688 KB Output is correct
14 Correct 914 ms 23784 KB Output is correct
15 Correct 1082 ms 23784 KB Output is correct
16 Correct 846 ms 23780 KB Output is correct
17 Correct 111 ms 23784 KB Output is correct
18 Correct 196 ms 23784 KB Output is correct
19 Correct 469 ms 23788 KB Output is correct
20 Correct 612 ms 23784 KB Output is correct
21 Correct 107 ms 23780 KB Output is correct
22 Correct 147 ms 23784 KB Output is correct
23 Correct 1671 ms 23780 KB Output is correct
24 Correct 741 ms 23788 KB Output is correct
25 Correct 1694 ms 23780 KB Output is correct
26 Correct 1925 ms 23788 KB Output is correct
27 Correct 1739 ms 23780 KB Output is correct
28 Correct 1372 ms 23788 KB Output is correct
29 Correct 201 ms 23764 KB Output is correct
30 Correct 868 ms 23784 KB Output is correct
31 Correct 252 ms 23784 KB Output is correct
32 Correct 1124 ms 23784 KB Output is correct
33 Correct 885 ms 23800 KB Output is correct
34 Correct 823 ms 23784 KB Output is correct
35 Correct 96 ms 23788 KB Output is correct
36 Correct 112 ms 23780 KB Output is correct
37 Correct 425 ms 23780 KB Output is correct
38 Correct 590 ms 23788 KB Output is correct
39 Correct 96 ms 23764 KB Output is correct
40 Correct 132 ms 23764 KB Output is correct
41 Correct 1549 ms 23784 KB Output is correct
42 Correct 672 ms 23784 KB Output is correct
43 Correct 1486 ms 23784 KB Output is correct
44 Correct 1745 ms 23780 KB Output is correct
45 Correct 1623 ms 23796 KB Output is correct
46 Correct 1175 ms 23788 KB Output is correct
47 Correct 106 ms 23788 KB Output is correct
48 Correct 146 ms 23784 KB Output is correct
49 Correct 3447 ms 23792 KB Output is correct
50 Correct 1490 ms 23788 KB Output is correct
51 Correct 3627 ms 23788 KB Output is correct
52 Correct 4050 ms 23808 KB Output is correct
53 Correct 3534 ms 23788 KB Output is correct
54 Correct 2929 ms 23784 KB Output is correct
55 Correct 173 ms 23784 KB Output is correct
56 Correct 801 ms 23784 KB Output is correct
57 Correct 233 ms 23784 KB Output is correct
58 Correct 854 ms 23784 KB Output is correct
59 Correct 901 ms 23784 KB Output is correct
60 Correct 780 ms 23764 KB Output is correct
61 Correct 95 ms 23788 KB Output is correct
62 Correct 119 ms 23780 KB Output is correct
63 Correct 428 ms 23784 KB Output is correct
64 Correct 613 ms 23784 KB Output is correct
65 Correct 95 ms 23764 KB Output is correct
66 Correct 130 ms 23780 KB Output is correct
67 Correct 1537 ms 23788 KB Output is correct
68 Correct 692 ms 23784 KB Output is correct
69 Correct 1498 ms 23784 KB Output is correct
70 Correct 1778 ms 23784 KB Output is correct
71 Correct 1602 ms 23784 KB Output is correct
72 Correct 1204 ms 23784 KB Output is correct
73 Correct 102 ms 23788 KB Output is correct
74 Correct 145 ms 23788 KB Output is correct
75 Correct 3440 ms 23784 KB Output is correct
76 Correct 1499 ms 23788 KB Output is correct
77 Correct 3659 ms 23784 KB Output is correct
78 Correct 4073 ms 23784 KB Output is correct
79 Correct 3485 ms 23808 KB Output is correct
80 Correct 2941 ms 23788 KB Output is correct
81 Runtime error 29 ms 48008 KB Execution killed with signal 11
82 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 23780 KB Output isn't correct
2 Halted 0 ms 0 KB -