Submission #592148

# Submission time Handle Problem Language Result Execution time Memory
592148 2022-07-08T16:41:25 Z tutis Uplifting Excursion (BOI22_vault) C++17
45 / 100
5000 ms 62712 KB
/*input
2 5
2 3 1 1 4

*/

#pragma GCC optimize ("O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using oset = tree<T,  null_type,  less<T>,  rb_tree_tag,  tree_order_statistics_node_update>;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 rng(0);
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int M;
	ll L;
	cin >> M >> L;
	ll A_[2 * M + 1];
	ll* A = A_ + M;
	for (int i = -M; i <= M; i++)
		cin >> A[i];
	ll pl = 0;
	pl += A[0];
	A[0] = 0;
	L = -L;
	ll cnt = 0;
	for (int l = -M; l <= M; l++)
	{
		L += l * A[l];
		cnt += A[l];
	}
	cc_hash_table<ll, ll>D;
	D[0] = 0;
	for (int v = M; v >= 1; v--)
		for (int l : {v, -v})
		{
			if (l == 0)
				continue;
			cc_hash_table<ll, ll>D_;
			for (pair<ll, ll>v : D)
			{
				ll k = (L - v.first) / l;
				k = max(k, 0ll);
				k = min(k, A[l]);
				ll lo = max(0ll, k - abs(l));
				ll hi = min(k + abs(l), A[l]);
				if (v.first + k * l == L)
				{
					ll c_ = v.second + k;
					auto it = D_.find(L);
					if (it == D_.end())
						D_[L] = c_;
					else
						it->second = min(it->second, c_);
				}
				else
					for (ll c = lo; c <= hi; c++)
					{
						ll v_ = v.first + l * c;
						ll c_ = v.second + c;
						auto it = D_.find(v_);
						if (it == D_.end())
							D_[v_] = c_;
						else
							it->second = min(it->second, c_);
					}
			}
			D = D_;
		}
	if (D.find(L) != D.end())
		cout << pl + cnt - D[L] << "\n";
	else
		cout << "impossible\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 852 ms 9096 KB Output is correct
6 Correct 754 ms 8592 KB Output is correct
7 Correct 271 ms 4640 KB Output is correct
8 Correct 729 ms 8760 KB Output is correct
9 Correct 1561 ms 16760 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 34 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 852 ms 9096 KB Output is correct
6 Correct 754 ms 8592 KB Output is correct
7 Correct 271 ms 4640 KB Output is correct
8 Correct 729 ms 8760 KB Output is correct
9 Correct 1561 ms 16760 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 34 ms 832 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 861 ms 9000 KB Output is correct
17 Correct 744 ms 8652 KB Output is correct
18 Correct 273 ms 4644 KB Output is correct
19 Correct 729 ms 8820 KB Output is correct
20 Correct 1558 ms 16616 KB Output is correct
21 Correct 32 ms 812 KB Output is correct
22 Correct 34 ms 832 KB Output is correct
23 Execution timed out 5069 ms 62712 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 35 ms 1316 KB Output is correct
3 Correct 14 ms 752 KB Output is correct
4 Correct 26 ms 1364 KB Output is correct
5 Correct 50 ms 1336 KB Output is correct
6 Correct 38 ms 1376 KB Output is correct
7 Correct 10 ms 468 KB Output is correct
8 Correct 10 ms 580 KB Output is correct
9 Correct 8 ms 468 KB Output is correct
10 Correct 13 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 35 ms 1316 KB Output is correct
3 Correct 14 ms 752 KB Output is correct
4 Correct 26 ms 1364 KB Output is correct
5 Correct 50 ms 1336 KB Output is correct
6 Correct 38 ms 1376 KB Output is correct
7 Correct 10 ms 468 KB Output is correct
8 Correct 10 ms 580 KB Output is correct
9 Correct 8 ms 468 KB Output is correct
10 Correct 13 ms 716 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 35 ms 1328 KB Output is correct
16 Correct 14 ms 752 KB Output is correct
17 Correct 26 ms 1324 KB Output is correct
18 Correct 48 ms 1352 KB Output is correct
19 Correct 41 ms 1440 KB Output is correct
20 Correct 10 ms 576 KB Output is correct
21 Correct 10 ms 468 KB Output is correct
22 Correct 7 ms 556 KB Output is correct
23 Correct 13 ms 716 KB Output is correct
24 Correct 24 ms 1232 KB Output is correct
25 Correct 42 ms 1416 KB Output is correct
26 Correct 147 ms 4184 KB Output is correct
27 Correct 30 ms 1348 KB Output is correct
28 Correct 108 ms 2440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 35 ms 1316 KB Output is correct
3 Correct 14 ms 752 KB Output is correct
4 Correct 26 ms 1364 KB Output is correct
5 Correct 50 ms 1336 KB Output is correct
6 Correct 38 ms 1376 KB Output is correct
7 Correct 10 ms 468 KB Output is correct
8 Correct 10 ms 580 KB Output is correct
9 Correct 8 ms 468 KB Output is correct
10 Correct 13 ms 716 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 38 ms 1308 KB Output is correct
13 Correct 16 ms 808 KB Output is correct
14 Correct 25 ms 1324 KB Output is correct
15 Correct 48 ms 1376 KB Output is correct
16 Correct 37 ms 1372 KB Output is correct
17 Correct 10 ms 540 KB Output is correct
18 Correct 10 ms 576 KB Output is correct
19 Correct 7 ms 564 KB Output is correct
20 Correct 12 ms 716 KB Output is correct
21 Correct 32 ms 812 KB Output is correct
22 Correct 35 ms 832 KB Output is correct
23 Correct 385 ms 4860 KB Output is correct
24 Correct 255 ms 4452 KB Output is correct
25 Correct 347 ms 4840 KB Output is correct
26 Correct 299 ms 7988 KB Output is correct
27 Correct 485 ms 8216 KB Output is correct
28 Correct 125 ms 2476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 852 ms 9096 KB Output is correct
6 Correct 754 ms 8592 KB Output is correct
7 Correct 271 ms 4640 KB Output is correct
8 Correct 729 ms 8760 KB Output is correct
9 Correct 1561 ms 16760 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 34 ms 832 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 35 ms 1316 KB Output is correct
14 Correct 14 ms 752 KB Output is correct
15 Correct 26 ms 1364 KB Output is correct
16 Correct 50 ms 1336 KB Output is correct
17 Correct 38 ms 1376 KB Output is correct
18 Correct 10 ms 468 KB Output is correct
19 Correct 10 ms 580 KB Output is correct
20 Correct 8 ms 468 KB Output is correct
21 Correct 13 ms 716 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 35 ms 1328 KB Output is correct
27 Correct 14 ms 752 KB Output is correct
28 Correct 26 ms 1324 KB Output is correct
29 Correct 48 ms 1352 KB Output is correct
30 Correct 41 ms 1440 KB Output is correct
31 Correct 10 ms 576 KB Output is correct
32 Correct 10 ms 468 KB Output is correct
33 Correct 7 ms 556 KB Output is correct
34 Correct 13 ms 716 KB Output is correct
35 Correct 24 ms 1232 KB Output is correct
36 Correct 42 ms 1416 KB Output is correct
37 Correct 147 ms 4184 KB Output is correct
38 Correct 30 ms 1348 KB Output is correct
39 Correct 108 ms 2440 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 38 ms 1308 KB Output is correct
42 Correct 16 ms 808 KB Output is correct
43 Correct 25 ms 1324 KB Output is correct
44 Correct 48 ms 1376 KB Output is correct
45 Correct 37 ms 1372 KB Output is correct
46 Correct 10 ms 540 KB Output is correct
47 Correct 10 ms 576 KB Output is correct
48 Correct 7 ms 564 KB Output is correct
49 Correct 12 ms 716 KB Output is correct
50 Correct 32 ms 812 KB Output is correct
51 Correct 35 ms 832 KB Output is correct
52 Correct 385 ms 4860 KB Output is correct
53 Correct 255 ms 4452 KB Output is correct
54 Correct 347 ms 4840 KB Output is correct
55 Correct 299 ms 7988 KB Output is correct
56 Correct 485 ms 8216 KB Output is correct
57 Correct 125 ms 2476 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 854 ms 9004 KB Output is correct
63 Correct 742 ms 8648 KB Output is correct
64 Correct 274 ms 4668 KB Output is correct
65 Correct 725 ms 8788 KB Output is correct
66 Correct 1604 ms 16608 KB Output is correct
67 Correct 34 ms 836 KB Output is correct
68 Correct 39 ms 832 KB Output is correct
69 Correct 37 ms 1344 KB Output is correct
70 Correct 16 ms 804 KB Output is correct
71 Correct 30 ms 1312 KB Output is correct
72 Correct 52 ms 1352 KB Output is correct
73 Correct 42 ms 1376 KB Output is correct
74 Correct 10 ms 584 KB Output is correct
75 Correct 11 ms 468 KB Output is correct
76 Correct 8 ms 560 KB Output is correct
77 Correct 14 ms 716 KB Output is correct
78 Correct 24 ms 1104 KB Output is correct
79 Correct 43 ms 1360 KB Output is correct
80 Correct 144 ms 4236 KB Output is correct
81 Correct 31 ms 1336 KB Output is correct
82 Correct 113 ms 2496 KB Output is correct
83 Correct 393 ms 4688 KB Output is correct
84 Correct 271 ms 4440 KB Output is correct
85 Correct 365 ms 4664 KB Output is correct
86 Correct 308 ms 8012 KB Output is correct
87 Correct 511 ms 8160 KB Output is correct
88 Correct 140 ms 2520 KB Output is correct
89 Correct 148 ms 2360 KB Output is correct
90 Correct 191 ms 3968 KB Output is correct
91 Correct 432 ms 9072 KB Output is correct
92 Correct 1281 ms 16028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 35 ms 1316 KB Output is correct
3 Correct 14 ms 752 KB Output is correct
4 Correct 26 ms 1364 KB Output is correct
5 Correct 50 ms 1336 KB Output is correct
6 Correct 38 ms 1376 KB Output is correct
7 Correct 10 ms 468 KB Output is correct
8 Correct 10 ms 580 KB Output is correct
9 Correct 8 ms 468 KB Output is correct
10 Correct 13 ms 716 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 38 ms 1308 KB Output is correct
13 Correct 16 ms 808 KB Output is correct
14 Correct 25 ms 1324 KB Output is correct
15 Correct 48 ms 1376 KB Output is correct
16 Correct 37 ms 1372 KB Output is correct
17 Correct 10 ms 540 KB Output is correct
18 Correct 10 ms 576 KB Output is correct
19 Correct 7 ms 564 KB Output is correct
20 Correct 12 ms 716 KB Output is correct
21 Correct 32 ms 812 KB Output is correct
22 Correct 35 ms 832 KB Output is correct
23 Correct 385 ms 4860 KB Output is correct
24 Correct 255 ms 4452 KB Output is correct
25 Correct 347 ms 4840 KB Output is correct
26 Correct 299 ms 7988 KB Output is correct
27 Correct 485 ms 8216 KB Output is correct
28 Correct 125 ms 2476 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 37 ms 1332 KB Output is correct
31 Correct 16 ms 812 KB Output is correct
32 Correct 30 ms 1388 KB Output is correct
33 Correct 55 ms 1372 KB Output is correct
34 Correct 46 ms 1392 KB Output is correct
35 Correct 10 ms 468 KB Output is correct
36 Correct 11 ms 576 KB Output is correct
37 Correct 8 ms 560 KB Output is correct
38 Correct 13 ms 716 KB Output is correct
39 Correct 35 ms 812 KB Output is correct
40 Correct 39 ms 816 KB Output is correct
41 Correct 403 ms 4640 KB Output is correct
42 Correct 270 ms 4436 KB Output is correct
43 Correct 396 ms 4680 KB Output is correct
44 Correct 321 ms 7996 KB Output is correct
45 Correct 485 ms 8236 KB Output is correct
46 Correct 125 ms 2408 KB Output is correct
47 Correct 258 ms 2368 KB Output is correct
48 Correct 268 ms 2272 KB Output is correct
49 Execution timed out 5087 ms 34792 KB Time limit exceeded
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 852 ms 9096 KB Output is correct
6 Correct 754 ms 8592 KB Output is correct
7 Correct 271 ms 4640 KB Output is correct
8 Correct 729 ms 8760 KB Output is correct
9 Correct 1561 ms 16760 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 34 ms 832 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 861 ms 9000 KB Output is correct
17 Correct 744 ms 8652 KB Output is correct
18 Correct 273 ms 4644 KB Output is correct
19 Correct 729 ms 8820 KB Output is correct
20 Correct 1558 ms 16616 KB Output is correct
21 Correct 32 ms 812 KB Output is correct
22 Correct 34 ms 832 KB Output is correct
23 Execution timed out 5069 ms 62712 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 35 ms 1316 KB Output is correct
3 Correct 14 ms 752 KB Output is correct
4 Correct 26 ms 1364 KB Output is correct
5 Correct 50 ms 1336 KB Output is correct
6 Correct 38 ms 1376 KB Output is correct
7 Correct 10 ms 468 KB Output is correct
8 Correct 10 ms 580 KB Output is correct
9 Correct 8 ms 468 KB Output is correct
10 Correct 13 ms 716 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 38 ms 1308 KB Output is correct
13 Correct 16 ms 808 KB Output is correct
14 Correct 25 ms 1324 KB Output is correct
15 Correct 48 ms 1376 KB Output is correct
16 Correct 37 ms 1372 KB Output is correct
17 Correct 10 ms 540 KB Output is correct
18 Correct 10 ms 576 KB Output is correct
19 Correct 7 ms 564 KB Output is correct
20 Correct 12 ms 716 KB Output is correct
21 Correct 32 ms 812 KB Output is correct
22 Correct 35 ms 832 KB Output is correct
23 Correct 385 ms 4860 KB Output is correct
24 Correct 255 ms 4452 KB Output is correct
25 Correct 347 ms 4840 KB Output is correct
26 Correct 299 ms 7988 KB Output is correct
27 Correct 485 ms 8216 KB Output is correct
28 Correct 125 ms 2476 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 37 ms 1332 KB Output is correct
31 Correct 16 ms 812 KB Output is correct
32 Correct 30 ms 1388 KB Output is correct
33 Correct 55 ms 1372 KB Output is correct
34 Correct 46 ms 1392 KB Output is correct
35 Correct 10 ms 468 KB Output is correct
36 Correct 11 ms 576 KB Output is correct
37 Correct 8 ms 560 KB Output is correct
38 Correct 13 ms 716 KB Output is correct
39 Correct 35 ms 812 KB Output is correct
40 Correct 39 ms 816 KB Output is correct
41 Correct 403 ms 4640 KB Output is correct
42 Correct 270 ms 4436 KB Output is correct
43 Correct 396 ms 4680 KB Output is correct
44 Correct 321 ms 7996 KB Output is correct
45 Correct 485 ms 8236 KB Output is correct
46 Correct 125 ms 2408 KB Output is correct
47 Correct 258 ms 2368 KB Output is correct
48 Correct 268 ms 2272 KB Output is correct
49 Execution timed out 5087 ms 34792 KB Time limit exceeded
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 852 ms 9096 KB Output is correct
6 Correct 754 ms 8592 KB Output is correct
7 Correct 271 ms 4640 KB Output is correct
8 Correct 729 ms 8760 KB Output is correct
9 Correct 1561 ms 16760 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 34 ms 832 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 861 ms 9000 KB Output is correct
17 Correct 744 ms 8652 KB Output is correct
18 Correct 273 ms 4644 KB Output is correct
19 Correct 729 ms 8820 KB Output is correct
20 Correct 1558 ms 16616 KB Output is correct
21 Correct 32 ms 812 KB Output is correct
22 Correct 34 ms 832 KB Output is correct
23 Execution timed out 5069 ms 62712 KB Time limit exceeded
24 Halted 0 ms 0 KB -