Submission #1224461

#TimeUsernameProblemLanguageResultExecution timeMemory
1224461amine_arouaPacking Biscuits (IOI20_biscuits)C++20
9 / 100
144 ms416 KiB
#include "biscuits.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX = 1e5;
long long count_tastiness(long long x, std::vector<long long> a) {
	int k = (int)a.size();
	// y * x <= MAX -> y <= MAX/x
	ll ans = 1;
	auto b = a;
	for(ll y = MAX/x ; y >= 1 ; y--)
	{
		b = a;
		bool possible = true;
		for(int i = 0 ; i < x ; i++)
		{
			int cur = y;
			for(int j = k - 1 ; j >= 0 ; j--)
			{
				ll nb = min(b[j] , cur / (1ll<<j));
				cur-= nb * (1ll<<j);
				b[j]-=nb;
			}
			if(cur)
			{
				possible = false;
				break;
			}
		}
		ans+=possible;
	}
	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...