Submission #592094

# Submission time Handle Problem Language Result Execution time Memory
592094 2022-07-08T13:41:46 Z tutis Uplifting Excursion (BOI22_vault) C++17
45 / 100
5000 ms 63188 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;
	ll del = M;
	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 - del);
				ll hi = min(k + del, 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 1156 ms 9420 KB Output is correct
6 Correct 1225 ms 15748 KB Output is correct
7 Correct 342 ms 4784 KB Output is correct
8 Correct 1083 ms 9420 KB Output is correct
9 Correct 3116 ms 17732 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 37 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 1156 ms 9420 KB Output is correct
6 Correct 1225 ms 15748 KB Output is correct
7 Correct 342 ms 4784 KB Output is correct
8 Correct 1083 ms 9420 KB Output is correct
9 Correct 3116 ms 17732 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 37 ms 832 KB Output is correct
12 Correct 1 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 1142 ms 9552 KB Output is correct
17 Correct 1241 ms 15728 KB Output is correct
18 Correct 348 ms 4712 KB Output is correct
19 Correct 1094 ms 9428 KB Output is correct
20 Correct 3100 ms 17836 KB Output is correct
21 Correct 32 ms 820 KB Output is correct
22 Correct 36 ms 792 KB Output is correct
23 Execution timed out 5090 ms 63188 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 55 ms 1376 KB Output is correct
3 Correct 27 ms 800 KB Output is correct
4 Correct 38 ms 1392 KB Output is correct
5 Correct 92 ms 2384 KB Output is correct
6 Correct 47 ms 1408 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 13 ms 572 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 25 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 55 ms 1376 KB Output is correct
3 Correct 27 ms 800 KB Output is correct
4 Correct 38 ms 1392 KB Output is correct
5 Correct 92 ms 2384 KB Output is correct
6 Correct 47 ms 1408 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 13 ms 572 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 25 ms 1236 KB Output is correct
11 Correct 0 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 55 ms 1384 KB Output is correct
16 Correct 18 ms 856 KB Output is correct
17 Correct 39 ms 1320 KB Output is correct
18 Correct 95 ms 2384 KB Output is correct
19 Correct 47 ms 1392 KB Output is correct
20 Correct 12 ms 584 KB Output is correct
21 Correct 10 ms 468 KB Output is correct
22 Correct 11 ms 724 KB Output is correct
23 Correct 30 ms 1272 KB Output is correct
24 Correct 38 ms 1260 KB Output is correct
25 Correct 70 ms 2216 KB Output is correct
26 Correct 245 ms 4452 KB Output is correct
27 Correct 46 ms 1364 KB Output is correct
28 Correct 204 ms 4168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 55 ms 1376 KB Output is correct
3 Correct 27 ms 800 KB Output is correct
4 Correct 38 ms 1392 KB Output is correct
5 Correct 92 ms 2384 KB Output is correct
6 Correct 47 ms 1408 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 13 ms 572 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 25 ms 1236 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 59 ms 1384 KB Output is correct
13 Correct 21 ms 852 KB Output is correct
14 Correct 43 ms 1396 KB Output is correct
15 Correct 96 ms 2404 KB Output is correct
16 Correct 57 ms 1392 KB Output is correct
17 Correct 11 ms 584 KB Output is correct
18 Correct 13 ms 576 KB Output is correct
19 Correct 13 ms 724 KB Output is correct
20 Correct 28 ms 1232 KB Output is correct
21 Correct 36 ms 828 KB Output is correct
22 Correct 42 ms 832 KB Output is correct
23 Correct 660 ms 8376 KB Output is correct
24 Correct 357 ms 4608 KB Output is correct
25 Correct 610 ms 8368 KB Output is correct
26 Correct 518 ms 8524 KB Output is correct
27 Correct 742 ms 8800 KB Output is correct
28 Correct 319 ms 4768 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 1156 ms 9420 KB Output is correct
6 Correct 1225 ms 15748 KB Output is correct
7 Correct 342 ms 4784 KB Output is correct
8 Correct 1083 ms 9420 KB Output is correct
9 Correct 3116 ms 17732 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 37 ms 832 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 55 ms 1376 KB Output is correct
14 Correct 27 ms 800 KB Output is correct
15 Correct 38 ms 1392 KB Output is correct
16 Correct 92 ms 2384 KB Output is correct
17 Correct 47 ms 1408 KB Output is correct
18 Correct 17 ms 468 KB Output is correct
19 Correct 13 ms 572 KB Output is correct
20 Correct 12 ms 724 KB Output is correct
21 Correct 25 ms 1236 KB Output is correct
22 Correct 0 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 55 ms 1384 KB Output is correct
27 Correct 18 ms 856 KB Output is correct
28 Correct 39 ms 1320 KB Output is correct
29 Correct 95 ms 2384 KB Output is correct
30 Correct 47 ms 1392 KB Output is correct
31 Correct 12 ms 584 KB Output is correct
32 Correct 10 ms 468 KB Output is correct
33 Correct 11 ms 724 KB Output is correct
34 Correct 30 ms 1272 KB Output is correct
35 Correct 38 ms 1260 KB Output is correct
36 Correct 70 ms 2216 KB Output is correct
37 Correct 245 ms 4452 KB Output is correct
38 Correct 46 ms 1364 KB Output is correct
39 Correct 204 ms 4168 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 59 ms 1384 KB Output is correct
42 Correct 21 ms 852 KB Output is correct
43 Correct 43 ms 1396 KB Output is correct
44 Correct 96 ms 2404 KB Output is correct
45 Correct 57 ms 1392 KB Output is correct
46 Correct 11 ms 584 KB Output is correct
47 Correct 13 ms 576 KB Output is correct
48 Correct 13 ms 724 KB Output is correct
49 Correct 28 ms 1232 KB Output is correct
50 Correct 36 ms 828 KB Output is correct
51 Correct 42 ms 832 KB Output is correct
52 Correct 660 ms 8376 KB Output is correct
53 Correct 357 ms 4608 KB Output is correct
54 Correct 610 ms 8368 KB Output is correct
55 Correct 518 ms 8524 KB Output is correct
56 Correct 742 ms 8800 KB Output is correct
57 Correct 319 ms 4768 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1256 ms 9492 KB Output is correct
63 Correct 1283 ms 15844 KB Output is correct
64 Correct 352 ms 4756 KB Output is correct
65 Correct 1123 ms 9300 KB Output is correct
66 Correct 3127 ms 18060 KB Output is correct
67 Correct 33 ms 812 KB Output is correct
68 Correct 35 ms 784 KB Output is correct
69 Correct 53 ms 1396 KB Output is correct
70 Correct 17 ms 852 KB Output is correct
71 Correct 37 ms 1396 KB Output is correct
72 Correct 98 ms 2384 KB Output is correct
73 Correct 47 ms 1336 KB Output is correct
74 Correct 12 ms 548 KB Output is correct
75 Correct 10 ms 468 KB Output is correct
76 Correct 11 ms 688 KB Output is correct
77 Correct 29 ms 1236 KB Output is correct
78 Correct 37 ms 1236 KB Output is correct
79 Correct 61 ms 2280 KB Output is correct
80 Correct 230 ms 4508 KB Output is correct
81 Correct 45 ms 1372 KB Output is correct
82 Correct 187 ms 4332 KB Output is correct
83 Correct 591 ms 8528 KB Output is correct
84 Correct 321 ms 4632 KB Output is correct
85 Correct 579 ms 8524 KB Output is correct
86 Correct 498 ms 8588 KB Output is correct
87 Correct 698 ms 8876 KB Output is correct
88 Correct 303 ms 4644 KB Output is correct
89 Correct 235 ms 2464 KB Output is correct
90 Correct 430 ms 4544 KB Output is correct
91 Correct 553 ms 9172 KB Output is correct
92 Correct 1947 ms 17436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 55 ms 1376 KB Output is correct
3 Correct 27 ms 800 KB Output is correct
4 Correct 38 ms 1392 KB Output is correct
5 Correct 92 ms 2384 KB Output is correct
6 Correct 47 ms 1408 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 13 ms 572 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 25 ms 1236 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 59 ms 1384 KB Output is correct
13 Correct 21 ms 852 KB Output is correct
14 Correct 43 ms 1396 KB Output is correct
15 Correct 96 ms 2404 KB Output is correct
16 Correct 57 ms 1392 KB Output is correct
17 Correct 11 ms 584 KB Output is correct
18 Correct 13 ms 576 KB Output is correct
19 Correct 13 ms 724 KB Output is correct
20 Correct 28 ms 1232 KB Output is correct
21 Correct 36 ms 828 KB Output is correct
22 Correct 42 ms 832 KB Output is correct
23 Correct 660 ms 8376 KB Output is correct
24 Correct 357 ms 4608 KB Output is correct
25 Correct 610 ms 8368 KB Output is correct
26 Correct 518 ms 8524 KB Output is correct
27 Correct 742 ms 8800 KB Output is correct
28 Correct 319 ms 4768 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 55 ms 1376 KB Output is correct
31 Correct 21 ms 856 KB Output is correct
32 Correct 39 ms 1384 KB Output is correct
33 Correct 92 ms 2380 KB Output is correct
34 Correct 47 ms 1548 KB Output is correct
35 Correct 10 ms 468 KB Output is correct
36 Correct 10 ms 468 KB Output is correct
37 Correct 12 ms 716 KB Output is correct
38 Correct 25 ms 1204 KB Output is correct
39 Correct 34 ms 812 KB Output is correct
40 Correct 35 ms 832 KB Output is correct
41 Correct 601 ms 8408 KB Output is correct
42 Correct 310 ms 4636 KB Output is correct
43 Correct 570 ms 8472 KB Output is correct
44 Correct 504 ms 8548 KB Output is correct
45 Correct 706 ms 8796 KB Output is correct
46 Correct 308 ms 4684 KB Output is correct
47 Correct 258 ms 2344 KB Output is correct
48 Correct 269 ms 2244 KB Output is correct
49 Execution timed out 5086 ms 36372 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 1156 ms 9420 KB Output is correct
6 Correct 1225 ms 15748 KB Output is correct
7 Correct 342 ms 4784 KB Output is correct
8 Correct 1083 ms 9420 KB Output is correct
9 Correct 3116 ms 17732 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 37 ms 832 KB Output is correct
12 Correct 1 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 1142 ms 9552 KB Output is correct
17 Correct 1241 ms 15728 KB Output is correct
18 Correct 348 ms 4712 KB Output is correct
19 Correct 1094 ms 9428 KB Output is correct
20 Correct 3100 ms 17836 KB Output is correct
21 Correct 32 ms 820 KB Output is correct
22 Correct 36 ms 792 KB Output is correct
23 Execution timed out 5090 ms 63188 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 55 ms 1376 KB Output is correct
3 Correct 27 ms 800 KB Output is correct
4 Correct 38 ms 1392 KB Output is correct
5 Correct 92 ms 2384 KB Output is correct
6 Correct 47 ms 1408 KB Output is correct
7 Correct 17 ms 468 KB Output is correct
8 Correct 13 ms 572 KB Output is correct
9 Correct 12 ms 724 KB Output is correct
10 Correct 25 ms 1236 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 59 ms 1384 KB Output is correct
13 Correct 21 ms 852 KB Output is correct
14 Correct 43 ms 1396 KB Output is correct
15 Correct 96 ms 2404 KB Output is correct
16 Correct 57 ms 1392 KB Output is correct
17 Correct 11 ms 584 KB Output is correct
18 Correct 13 ms 576 KB Output is correct
19 Correct 13 ms 724 KB Output is correct
20 Correct 28 ms 1232 KB Output is correct
21 Correct 36 ms 828 KB Output is correct
22 Correct 42 ms 832 KB Output is correct
23 Correct 660 ms 8376 KB Output is correct
24 Correct 357 ms 4608 KB Output is correct
25 Correct 610 ms 8368 KB Output is correct
26 Correct 518 ms 8524 KB Output is correct
27 Correct 742 ms 8800 KB Output is correct
28 Correct 319 ms 4768 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 55 ms 1376 KB Output is correct
31 Correct 21 ms 856 KB Output is correct
32 Correct 39 ms 1384 KB Output is correct
33 Correct 92 ms 2380 KB Output is correct
34 Correct 47 ms 1548 KB Output is correct
35 Correct 10 ms 468 KB Output is correct
36 Correct 10 ms 468 KB Output is correct
37 Correct 12 ms 716 KB Output is correct
38 Correct 25 ms 1204 KB Output is correct
39 Correct 34 ms 812 KB Output is correct
40 Correct 35 ms 832 KB Output is correct
41 Correct 601 ms 8408 KB Output is correct
42 Correct 310 ms 4636 KB Output is correct
43 Correct 570 ms 8472 KB Output is correct
44 Correct 504 ms 8548 KB Output is correct
45 Correct 706 ms 8796 KB Output is correct
46 Correct 308 ms 4684 KB Output is correct
47 Correct 258 ms 2344 KB Output is correct
48 Correct 269 ms 2244 KB Output is correct
49 Execution timed out 5086 ms 36372 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 1156 ms 9420 KB Output is correct
6 Correct 1225 ms 15748 KB Output is correct
7 Correct 342 ms 4784 KB Output is correct
8 Correct 1083 ms 9420 KB Output is correct
9 Correct 3116 ms 17732 KB Output is correct
10 Correct 32 ms 812 KB Output is correct
11 Correct 37 ms 832 KB Output is correct
12 Correct 1 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 1142 ms 9552 KB Output is correct
17 Correct 1241 ms 15728 KB Output is correct
18 Correct 348 ms 4712 KB Output is correct
19 Correct 1094 ms 9428 KB Output is correct
20 Correct 3100 ms 17836 KB Output is correct
21 Correct 32 ms 820 KB Output is correct
22 Correct 36 ms 792 KB Output is correct
23 Execution timed out 5090 ms 63188 KB Time limit exceeded
24 Halted 0 ms 0 KB -