Submission #466988

#TimeUsernameProblemLanguageResultExecution timeMemory
466988armandPacking Biscuits (IOI20_biscuits)C++14
0 / 100
1081 ms332 KiB
#include "biscuits.h"
#include <algorithm>
using namespace std;

int check_y(long long x, std::vector<long long> a, int y)
{
	int i, k = a.size();
	for (i = 0; i < k; i++)
		if ((1 << i) > y)
			break;
	i--;
	long long t = y * x;
	while (i>=0) {
		long long p = t / (1 << i);
		t -= min(a[i], p)*(1 << i);
		if (t == 0)
			return 1;
		i--;
	}
	return t == 0;
}

long long count_tastiness(long long x, std::vector<long long> a) 
{
	int k = a.size();
	int res = 1;
	for (int y = 1; y <= 100000; y++)
		res += check_y(x, a, y);
	return res;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:25:6: warning: unused variable 'k' [-Wunused-variable]
   25 |  int k = a.size();
      |      ^
#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...