Submission #304384

#TimeUsernameProblemLanguageResultExecution timeMemory
304384arnold518Packing Biscuits (IOI20_biscuits)C++14
0 / 100
3 ms384 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll X, A[100], P;

bool solve(ll y)
{
	ll now=0;
	for(int i=59; i>=0; i--)
	{
		if(y&(1ll<<i)) now+=X;
		now=max(0ll, now-A[i]);
		now*=2;
	}
	return now==0;
}

ll count_tastiness(ll _X, vector<ll> _A)
{
	X=_X; P=0;
	memset(A, 0, sizeof(A));
	for(int i=0; i<_A.size(); i++) A[i]=_A[i];

	for(int i=0; i<60; i++) P+=(1ll<<i)*A[i];

	ll now=0, cnt=0, ans=0;
	vector<ll> V;
	for(int i=0; i<60; i++)
	{
		now+=A[i];
		if(now!=0)
		{
			if(P&(1ll<<i)) V.push_back(1);
			else V.push_back(0);
		}
		now/=2;
	}
	for(int i=0; i<V.size(); i++) ans+=(ll)V[i]<<i;

	return ans+1;
}

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i=0; i<_A.size(); i++) A[i]=_A[i];
      |               ~^~~~~~~~~~
biscuits.cpp:43:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for(int i=0; i<V.size(); i++) ans+=(ll)V[i]<<i;
      |               ~^~~~~~~~~
biscuits.cpp:31:12: warning: unused variable 'cnt' [-Wunused-variable]
   31 |  ll now=0, cnt=0, ans=0;
      |            ^~~
#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...