Submission #590375

# Submission time Handle Problem Language Result Execution time Memory
590375 2022-07-05T21:48:38 Z tutis Uplifting Excursion (BOI22_vault) C++17
5 / 100
5000 ms 8364 KB
/*input
2 5
2 3 1 1 4
*/
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
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];
	int D = 505000;
	vector<int> C(2 * D + 1, -1e18);
	C[D] = 0;
	int sum = 0;
	for (int i = 1; i <= M; i++)
	{
		for (int j = D + sum; j >= D - sum; j--)
		{
			for (int k = 1; k <= A[i + M]; k++)
			{
				if (j + k * i <= 2 * D)
					C[j + k * i] = max(C[j + k * i], C[j] + k);
			}
		}
		sum += i * max(A[i + M], A[-i + M]);
		for (int j = D - sum; j <= D + sum; j++)
		{
			for (int k = 1; k <= A[-i + M]; k++)
			{
				if (j - k * i >= 0)
					C[j - k * i] = max(C[j - k * i], C[j] + k);
			}
		}
	}
	if (L + D >= 0 && L + D <= 2 * D && C[L + D] >= 0)
		cout << C[L + D] + A[M] << "\n";
	else
		cout << "impossible\n";
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:23:27: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '-1.0e+18' to '-2147483648' [-Woverflow]
   23 |  vector<int> C(2 * D + 1, -1e18);
      |                           ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 88 ms 4180 KB Output is correct
6 Correct 97 ms 4180 KB Output is correct
7 Correct 26 ms 4180 KB Output is correct
8 Correct 100 ms 4180 KB Output is correct
9 Correct 232 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 88 ms 4180 KB Output is correct
6 Correct 97 ms 4180 KB Output is correct
7 Correct 26 ms 4180 KB Output is correct
8 Correct 100 ms 4180 KB Output is correct
9 Correct 232 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4180 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 3 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 87 ms 4180 KB Output is correct
17 Correct 118 ms 4180 KB Output is correct
18 Correct 25 ms 4180 KB Output is correct
19 Correct 86 ms 4180 KB Output is correct
20 Correct 258 ms 4180 KB Output is correct
21 Correct 2 ms 4180 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 2530 ms 4180 KB Output is correct
24 Correct 2440 ms 4180 KB Output is correct
25 Correct 537 ms 4180 KB Output is correct
26 Execution timed out 5058 ms 4180 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Runtime error 481 ms 8364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Runtime error 481 ms 8364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Runtime error 481 ms 8364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 88 ms 4180 KB Output is correct
6 Correct 97 ms 4180 KB Output is correct
7 Correct 26 ms 4180 KB Output is correct
8 Correct 100 ms 4180 KB Output is correct
9 Correct 232 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4180 KB Output is correct
13 Runtime error 481 ms 8364 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Runtime error 481 ms 8364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 88 ms 4180 KB Output is correct
6 Correct 97 ms 4180 KB Output is correct
7 Correct 26 ms 4180 KB Output is correct
8 Correct 100 ms 4180 KB Output is correct
9 Correct 232 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4180 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 3 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 87 ms 4180 KB Output is correct
17 Correct 118 ms 4180 KB Output is correct
18 Correct 25 ms 4180 KB Output is correct
19 Correct 86 ms 4180 KB Output is correct
20 Correct 258 ms 4180 KB Output is correct
21 Correct 2 ms 4180 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 2530 ms 4180 KB Output is correct
24 Correct 2440 ms 4180 KB Output is correct
25 Correct 537 ms 4180 KB Output is correct
26 Execution timed out 5058 ms 4180 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Runtime error 481 ms 8364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 88 ms 4180 KB Output is correct
6 Correct 97 ms 4180 KB Output is correct
7 Correct 26 ms 4180 KB Output is correct
8 Correct 100 ms 4180 KB Output is correct
9 Correct 232 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4180 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 3 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 87 ms 4180 KB Output is correct
17 Correct 118 ms 4180 KB Output is correct
18 Correct 25 ms 4180 KB Output is correct
19 Correct 86 ms 4180 KB Output is correct
20 Correct 258 ms 4180 KB Output is correct
21 Correct 2 ms 4180 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 2530 ms 4180 KB Output is correct
24 Correct 2440 ms 4180 KB Output is correct
25 Correct 537 ms 4180 KB Output is correct
26 Execution timed out 5058 ms 4180 KB Time limit exceeded
27 Halted 0 ms 0 KB -