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 lli long long int
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define MAX 70
lli n,res,cant,sec,bloque;
lli pot[64];
void calcula() {
pot[0] = 1;
rep(i,1,63) pot[i] = pot[i-1]*2;
}
long long count_tastiness(long long x, std::vector<long long> a) {
if (pot[0] == 0) calcula();
n = a.size();
rep(i,n,64) a.push_back(0);
n = 64;
cant = 0;
res = 0;
sec = 0;
bloque = 0;
if (x > 1) return 0;
rep(i,0,n-1) {
if (a[i] > 0) {
cant++;
bloque++;
if (a[i]%2 == 0){
a[i+1] += (a[i]-1)/2;
sec++;
}
else a[i+1] += a[i]/2;
}
else if (bloque > 0){
res += pot[sec] - 1;
bloque = 0;
}
}
res += (pot[cant]-1);
res++;
return res;
}
# | 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... |