# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
614072 | penguinhacker | Packing Biscuits (IOI20_biscuits) | C++17 | 9 ms | 1192 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;
#define ll long long
#define ar array
ll count_tastiness(ll x, vector<ll> a) {
vector<ll> v(60);
for (int i=0; i<a.size(); ++i)
v[i]+=(1ll*a[i])<<i;
for (int i=1; i<60; ++i)
v[i]+=v[i-1];
for (int i=0; i<60; ++i)
v[i]/=x;
vector<ar<ll, 2>> dp(60);
for (int i=0; i<60; ++i) {
dp[i][0]=i?dp[i-1][0]+dp[i-1][1]:1;
if (v[i]>=(1ll<<i+1)-1)
dp[i][1]=dp[i][0];
else if (v[i]>=1ll<<i) {
dp[i][1]=1;
for (ll x=v[i]-(1ll<<i); x;) {
int bit=63-__builtin_clzll(x);
dp[i][1]+=dp[bit][0];
x-=1ll<<bit;
}
//dp[i][1]=(v[i]==1ll<<i)?1:dp[63-__builtin_clzll(v[i]-(1ll<<i))][1]+dp[63-__builtin_clzll(v[i]-(1ll<<i))][0];
}
//if (i<3)
// cout << dp[i][0] << " " << dp[i][1] << endl;
}
return dp[59][0]+dp[59][1];
}
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... |