Submission #592092

# Submission time Handle Problem Language Result Execution time Memory
592092 2022-07-08T13:39:37 Z tutis Uplifting Excursion (BOI22_vault) C++17
30 / 100
5000 ms 11512 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];
	}
	map<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;
			map<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.count(L))
		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 Execution timed out 5069 ms 8140 KB Time limit exceeded
6 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 Execution timed out 5069 ms 8140 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 149 ms 1180 KB Output is correct
3 Correct 26 ms 672 KB Output is correct
4 Correct 107 ms 1072 KB Output is correct
5 Correct 276 ms 1572 KB Output is correct
6 Correct 113 ms 1124 KB Output is correct
7 Correct 9 ms 468 KB Output is correct
8 Correct 9 ms 468 KB Output is correct
9 Correct 21 ms 624 KB Output is correct
10 Correct 58 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 149 ms 1180 KB Output is correct
3 Correct 26 ms 672 KB Output is correct
4 Correct 107 ms 1072 KB Output is correct
5 Correct 276 ms 1572 KB Output is correct
6 Correct 113 ms 1124 KB Output is correct
7 Correct 9 ms 468 KB Output is correct
8 Correct 9 ms 468 KB Output is correct
9 Correct 21 ms 624 KB Output is correct
10 Correct 58 ms 892 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 150 ms 1212 KB Output is correct
16 Correct 27 ms 628 KB Output is correct
17 Correct 104 ms 1196 KB Output is correct
18 Correct 296 ms 1748 KB Output is correct
19 Correct 112 ms 1136 KB Output is correct
20 Correct 9 ms 480 KB Output is correct
21 Correct 9 ms 468 KB Output is correct
22 Correct 20 ms 584 KB Output is correct
23 Correct 57 ms 748 KB Output is correct
24 Correct 146 ms 908 KB Output is correct
25 Correct 151 ms 1356 KB Output is correct
26 Correct 1076 ms 3556 KB Output is correct
27 Correct 188 ms 1224 KB Output is correct
28 Correct 742 ms 2768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 149 ms 1180 KB Output is correct
3 Correct 26 ms 672 KB Output is correct
4 Correct 107 ms 1072 KB Output is correct
5 Correct 276 ms 1572 KB Output is correct
6 Correct 113 ms 1124 KB Output is correct
7 Correct 9 ms 468 KB Output is correct
8 Correct 9 ms 468 KB Output is correct
9 Correct 21 ms 624 KB Output is correct
10 Correct 58 ms 892 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 147 ms 1232 KB Output is correct
13 Correct 25 ms 692 KB Output is correct
14 Correct 108 ms 1196 KB Output is correct
15 Correct 278 ms 1648 KB Output is correct
16 Correct 111 ms 1188 KB Output is correct
17 Correct 8 ms 468 KB Output is correct
18 Correct 9 ms 488 KB Output is correct
19 Correct 20 ms 580 KB Output is correct
20 Correct 60 ms 832 KB Output is correct
21 Correct 28 ms 596 KB Output is correct
22 Correct 33 ms 676 KB Output is correct
23 Correct 2728 ms 5396 KB Output is correct
24 Correct 982 ms 3644 KB Output is correct
25 Correct 2700 ms 5240 KB Output is correct
26 Correct 3076 ms 5872 KB Output is correct
27 Correct 3463 ms 6240 KB Output is correct
28 Correct 1377 ms 3500 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 Execution timed out 5069 ms 8140 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 149 ms 1180 KB Output is correct
3 Correct 26 ms 672 KB Output is correct
4 Correct 107 ms 1072 KB Output is correct
5 Correct 276 ms 1572 KB Output is correct
6 Correct 113 ms 1124 KB Output is correct
7 Correct 9 ms 468 KB Output is correct
8 Correct 9 ms 468 KB Output is correct
9 Correct 21 ms 624 KB Output is correct
10 Correct 58 ms 892 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 147 ms 1232 KB Output is correct
13 Correct 25 ms 692 KB Output is correct
14 Correct 108 ms 1196 KB Output is correct
15 Correct 278 ms 1648 KB Output is correct
16 Correct 111 ms 1188 KB Output is correct
17 Correct 8 ms 468 KB Output is correct
18 Correct 9 ms 488 KB Output is correct
19 Correct 20 ms 580 KB Output is correct
20 Correct 60 ms 832 KB Output is correct
21 Correct 28 ms 596 KB Output is correct
22 Correct 33 ms 676 KB Output is correct
23 Correct 2728 ms 5396 KB Output is correct
24 Correct 982 ms 3644 KB Output is correct
25 Correct 2700 ms 5240 KB Output is correct
26 Correct 3076 ms 5872 KB Output is correct
27 Correct 3463 ms 6240 KB Output is correct
28 Correct 1377 ms 3500 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 151 ms 1180 KB Output is correct
31 Correct 25 ms 696 KB Output is correct
32 Correct 112 ms 1256 KB Output is correct
33 Correct 278 ms 1612 KB Output is correct
34 Correct 125 ms 1136 KB Output is correct
35 Correct 9 ms 468 KB Output is correct
36 Correct 9 ms 488 KB Output is correct
37 Correct 20 ms 584 KB Output is correct
38 Correct 59 ms 836 KB Output is correct
39 Correct 28 ms 596 KB Output is correct
40 Correct 34 ms 596 KB Output is correct
41 Correct 2710 ms 5192 KB Output is correct
42 Correct 990 ms 3712 KB Output is correct
43 Correct 2722 ms 5064 KB Output is correct
44 Correct 3014 ms 5892 KB Output is correct
45 Correct 3454 ms 6208 KB Output is correct
46 Correct 1345 ms 3564 KB Output is correct
47 Correct 271 ms 1492 KB Output is correct
48 Correct 316 ms 1660 KB Output is correct
49 Execution timed out 5074 ms 11512 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 Execution timed out 5069 ms 8140 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 149 ms 1180 KB Output is correct
3 Correct 26 ms 672 KB Output is correct
4 Correct 107 ms 1072 KB Output is correct
5 Correct 276 ms 1572 KB Output is correct
6 Correct 113 ms 1124 KB Output is correct
7 Correct 9 ms 468 KB Output is correct
8 Correct 9 ms 468 KB Output is correct
9 Correct 21 ms 624 KB Output is correct
10 Correct 58 ms 892 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 147 ms 1232 KB Output is correct
13 Correct 25 ms 692 KB Output is correct
14 Correct 108 ms 1196 KB Output is correct
15 Correct 278 ms 1648 KB Output is correct
16 Correct 111 ms 1188 KB Output is correct
17 Correct 8 ms 468 KB Output is correct
18 Correct 9 ms 488 KB Output is correct
19 Correct 20 ms 580 KB Output is correct
20 Correct 60 ms 832 KB Output is correct
21 Correct 28 ms 596 KB Output is correct
22 Correct 33 ms 676 KB Output is correct
23 Correct 2728 ms 5396 KB Output is correct
24 Correct 982 ms 3644 KB Output is correct
25 Correct 2700 ms 5240 KB Output is correct
26 Correct 3076 ms 5872 KB Output is correct
27 Correct 3463 ms 6240 KB Output is correct
28 Correct 1377 ms 3500 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 151 ms 1180 KB Output is correct
31 Correct 25 ms 696 KB Output is correct
32 Correct 112 ms 1256 KB Output is correct
33 Correct 278 ms 1612 KB Output is correct
34 Correct 125 ms 1136 KB Output is correct
35 Correct 9 ms 468 KB Output is correct
36 Correct 9 ms 488 KB Output is correct
37 Correct 20 ms 584 KB Output is correct
38 Correct 59 ms 836 KB Output is correct
39 Correct 28 ms 596 KB Output is correct
40 Correct 34 ms 596 KB Output is correct
41 Correct 2710 ms 5192 KB Output is correct
42 Correct 990 ms 3712 KB Output is correct
43 Correct 2722 ms 5064 KB Output is correct
44 Correct 3014 ms 5892 KB Output is correct
45 Correct 3454 ms 6208 KB Output is correct
46 Correct 1345 ms 3564 KB Output is correct
47 Correct 271 ms 1492 KB Output is correct
48 Correct 316 ms 1660 KB Output is correct
49 Execution timed out 5074 ms 11512 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 Execution timed out 5069 ms 8140 KB Time limit exceeded
6 Halted 0 ms 0 KB -