Submission #466011

#TimeUsernameProblemLanguageResultExecution timeMemory
466011blue비스킷 담기 (IOI20_biscuits)C++17
0 / 100
1090 ms772 KiB
#include "biscuits.h"
#include <vector>
using namespace std;

//x = number of people (p)
//y = tastiness of each bag (i)

long long count_tastiness(long long x, vector<long long> a)
{
	int k = a.size();
	long long ans = 0;

	long long a_sum = 0;
	for(int i = 0; i < k; i++)
		a_sum += a[i] * (1 << i);


	if(x > a_sum) return 1;

	for(long long y = 0; x*y <= a_sum; y++)
	{
		vector<long long> value(x, 0);

		vector<long long> A = a;

		for(int i = k-1; i >= 0; i--)
		{
			for(int p = 0; p < x; p++)
			{
				while(A[i] > 0 && value[p] + (1 << i) <= y)
				{
					value[p] += (1 << i);
					A[i]--;
				}
			}
		}

		bool good = 1;
		for(int p = 0; p < x; p++)
			if(value[p] != y)
				good = 0;

		if(good)
			ans++;
	}

	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...