Submission #303538

# Submission time Handle Problem Language Result Execution time Memory
303538 2020-09-20T11:43:01 Z tutis Packing Biscuits (IOI20_biscuits) C++17
42 / 100
1000 ms 19444 KB
#include "biscuits.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
ll count_tastiness(ll x, vector<ll> a)
{
	while (a.size() <= 60)
		a.push_back(0);
	ll s[61];
	s[60] = 0;
	for (int i = 59; i >= 0; i--)
	{
		s[i] = a[i] + s[i + 1] * 2;
		if (s[i] >= 3 * x)
			s[i] = 3 * x;
	}
	cc_hash_table<ll, ll>M[61];
	function<ll(ll, int)>get = [&](ll d, int i)->ll
	{
		if (i == 60)
			return d / x + 1;
		if (s[i] + d < x)
			return 1;
		if (s[i] + d < 2 * x)
		{
			if (a[i] + d >= x)
				return 2;
			else
				return 1;
		}
		if (s[i] + d < 3 * x)
		{
			ll ret = 1;
			if (a[i] + d >= x)
				ret++;
			if ((a[i] + d) / 2 + a[i + 1] >= x)
				ret++;
			return ret;
		}
		if (M[i].find(d) != M[i].end())
			return M[i][d];
		if (a[i] + d < x)
		{
			return M[i][d] = get((d + a[i]) / 2, i + 1);
		}
		else
		{
			return M[i][d] = get((d + a[i]) / 2, i + 1) + get((d + a[i] - x) / 2, i + 1);
		}
	};
	return get(0, 0);
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 18796 KB Output is correct
2 Correct 133 ms 7672 KB Output is correct
3 Correct 236 ms 15236 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 618 ms 19444 KB Output is correct
9 Correct 404 ms 13132 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 10 ms 688 KB Output is correct
12 Correct 90 ms 3252 KB Output is correct
13 Correct 680 ms 18820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 5564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 76 ms 18796 KB Output is correct
25 Correct 133 ms 7672 KB Output is correct
26 Correct 236 ms 15236 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 618 ms 19444 KB Output is correct
32 Correct 404 ms 13132 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 10 ms 688 KB Output is correct
35 Correct 90 ms 3252 KB Output is correct
36 Correct 680 ms 18820 KB Output is correct
37 Execution timed out 1093 ms 5564 KB Time limit exceeded
38 Halted 0 ms 0 KB -