Submission #590639

# Submission time Handle Problem Language Result Execution time Memory
590639 2022-07-06T07:56:17 Z tutis Uplifting Excursion (BOI22_vault) C++17
0 / 100
5000 ms 3120 KB
/*input
1 5
0 0 6

*/

#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;
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];
	for (int i = 0; i <= 2 * M; i++)
		cin >> A[i];
	array<array<pair<ll, ll>, 300>, 301> v;
	for (int m = 1; m <= 300; m++)
	{
		for (int k = 0; k < m; k++)
			v[m][k] = { -3e18, -3e18};
		v[m][0] = {0, 0};
	}
	ll ret = -1;
	for (ll i = M; i >= 1; i--)
	{
		auto w = v;
		for (ll m = 1; m <= 300; m++)
			for (ll k = 0; k < m; k++)
			{
				ll x = v[m][k].first;
				ll mx = (L - x) / i;
				mx = min(mx, A[i + M]);
				for (ll c = mx; c >= 0 && c >= mx - 300; c--)
				{
					ll val = x + i * c;
					ll cnt = v[m][k].second + c;
					for (ll md = 1; md <= 300; md++)
					{
						ll vv = val % md;
						w[md][vv] = max(w[md][vv], {val, cnt});
					}
				}
			}
		v = w;
	}
	for (int m = 1; m <= 300; m++)
		for (int k = 0; k < m; k++)
			if (v[m][k].first == L)
				ret = max(ret, v[m][k].second);
	if (ret < 0)
		cout << "impossible\n";
	else
		cout << ret + A[M] << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1439 ms 3120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1439 ms 3120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5079 ms 3028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5079 ms 3028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5079 ms 3028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1439 ms 3120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5079 ms 3028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1439 ms 3120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5079 ms 3028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1439 ms 3120 KB Output isn't correct
2 Halted 0 ms 0 KB -