# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1031131 | happy_node | Packing Biscuits (IOI20_biscuits) | C++17 | 1060 ms | 18604 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;
long long count_tastiness(long long X, std::vector<long long> a) {
while(a.size()<60) a.push_back(0);
int K=a.size();
vector<pair<ll,ll>> dp;
dp.push_back({0,1}); // (balance, distinct ways)
for(int b=0;b<60;b++) {
vector<pair<ll,ll>> ndp;
for(auto [x,y]:dp) {
ndp.push_back({(x+a[b])/2,y}); // do nothing
if(x+a[b]>=X)
ndp.push_back({(x+a[b]-X)/2,y}); // create new stuff
}
sort(ndp.begin(),ndp.end());
vector<pair<ll,ll>> nxt;
for(int i=0;i<ndp.size();i++) {
int j=i;
ll sum=ndp[i].second;
while(j+1<ndp.size() && ndp[j+1].first==ndp[j].first) j++, sum+=ndp[j].second;
nxt.push_back({ndp[i].first,sum});
i=j;
}
swap(dp,nxt);
}
ll sum=0;
for(auto [x,y]:dp) sum+=y;
return sum;
}
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... |