# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
566798 | 2fat2code | Packing Biscuits (IOI20_biscuits) | C++17 | 1079 ms | 340 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>
#define fr first
#define sc second
#define all(s) s.begin(), s.end()
#define int long long
using namespace std;
int ans, k;
int count_tastiness(int x, vector<int> a) {
ans = 1LL;
if(x == 1){
k = (int)a.size();
for(int i=0;i<(int)a.size();i++){
if(a[i] >= 3){
if(i == a.size() - 1){
a.push_back(0);
}
a[i + 1] += ( (a[i] - 1LL) / 2LL);
if(a[i] % 2 == 1LL) a[i] = 1;
else a[i]= 2;
}
}
int j = 0;
while(j < (int)a.size()){
int curr = 0;
int pos = j;
while(j < (int)a.size() && a[j] != 0){
curr = (curr + a[j] * (1LL << (j - pos)));
++j;
}
curr++;
ans *= curr;
j++;
}
}
else{
ans = 1;
int sum = 0;
int nrbiti = (int)a.size();
for(int i=0;i<nrbiti;i++){
sum += a[i] * (1LL << i);
}
for(int curr=1;curr<=(sum/x);curr++){
vector<int>b = a;
b.push_back(0);
for(int i=0;(1LL<<i)<=curr;i++){
if(i == b.size() - 1) b.push_back(0);
if(curr & (1LL<<i) && b[i] < x){
goto next;
}
else{
if(curr & (1LL << i)) b[i] -= x;
b[i+1] += (b[i] / 2);
}
}
++ans;
next:;
}
}
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... |