# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
304373 | arnold518 | Packing Biscuits (IOI20_biscuits) | C++14 | 2 ms | 456 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
for(int i=0; i<60; i++)
{
now+=A[i];
if(now!=0) cnt++;
now/=2;
}
return (1ll<<cnt);
ll ans=0;
for(ll i=0; i<=P/X; i++)
{
ans+=solve(i);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |