Submission #1351851

#TimeUsernameProblemLanguageResultExecution timeMemory
1351851Jawad_Akbar_JJPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1094 ms484 KiB
#include <iostream>
#include <vector>

using namespace std;

long long count_tastiness(long long x, vector<long long> c){
	int ans = 0, sum = 0, k = c.size();
	for (int i=0;i<k;i++)
		sum += c[i]<<i;

	for (int y=1;y * x <= sum;y++){
		vector<long long> C = c;
		int t = 1;
		for (int j = 18, l = k - 1;j + 1; j--){
			while (l > j)
				l--;
			if ((y & (1<<j)) == 0)
				continue;
			long long req = x;
			while (req > 0 and l >= 0){
				int kk = min(req, C[l]);
				C[l] -= kk;
				req -= kk;
				req *= 2;
				if (C[l] == 0)
					l--;
			}
			if (req > 0)
				t = 0;
		}
		ans += t;
	}
	return ans + 1;
}
#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...