# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781511 | _martynas | Packing Biscuits (IOI20_biscuits) | C++14 | 1 ms | 616 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 <set>
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;
#warning change mxk to 60
const int mxk = 60;
ll count_tastiness(ll x, vector<ll> a) {
assert(x == 1);
vector<ll> dp(mxk+1); // dp[i] - ways to use first i bits
dp[0] = 1;
a.resize(mxk, 0);
vector<ll> pref(mxk);
for(int i = 0; i < mxk; i++) {
pref[i] = (i ? pref[i-1] : 0) + (1LL<<i)*a[i];
}
// for(int y : a) cerr << y << " ";
// cerr << "\n";
for(int i = 1; i <= mxk; i++) {
// i-th bit is 0
dp[i] = dp[i-1];
// i-th bit is 1
if(a[i-1] > 0) {
dp[i] += dp[i-1];
}
else {
ll mx = 1LL << (i-1);
mx = pref[i-1]-mx;
if(mx >= (1LL << (i-1))) {
dp[i] += dp[i-1];
}
else if(mx >= 0) {
dp[i]++;
for(int b = 0; b < i-1; b++) {
if(mx & (1LL << b)) {
dp[i] += dp[b];
}
}
}
}
}
// for(auto y : dp) cerr << y << " ";
// cerr << "\n";
return dp[mxk];
}
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... |