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 N 200005
using namespace std;
long long vals[N];
long long count_tastiness(long long x, vector<long long> a){
int k = a.size();
vector<long long> pre = a;
for(int i = 1;i<k;i++){
pre[i] = pre[i-1] + a[i] * (1ll<<i);
}
for(int i = 0;i<k;i++){
pre[i] /= x;
//cout << i << " " << pre[i] << endl;
}
for(int i = k-2;i>=0;i--){
pre[i] = min(pre[i],pre[i+1]);
}
vals[0] = 0;
int sz = 1;
for(int i = 0;i<62;i++){
int tmp = sz;
for(int j = 0;j<tmp;j++){
if(vals[j] + (1ll<<i) <= pre[min(i,k-1)]){
vals[sz++] = vals[j] + (1ll<<i);
}
else break;
}
}
long long ans = sz;
/*
long long ans = 0;
for(int i = 0;i<=pre[k-1];i++){
bool ok = 1;
for(int j = 0;j<k;j++){
if(pre[j] < (i & ((1<<(j+1))-1)) ){
ok = 0;
}
}
ans += ok;
}*/
return ans;
}
# | 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... |