#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = -1;
const int inf=1000000500ll;
const long long oo =1000000000000000500ll;
const int MOD = (int)1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi;
int ans;
long long count_tastiness(long long X, std::vector<long long> vec) {
ans=1;//0
int L=vec.size();
while((int)vec.size()<2*L)vec.push_back(0);
for(int i=0;i<2*L;i++){ // let's count the numbers st the biggest bit is 2^i
int smallest=max(0ll,i-60);
/*
int debt=0;
for(int j=i-1;j>=0;j--){ // let's find smallest j such that i can fill everything from [j,i-1]
debt*=2;
debt+=X;
debt-=vec[j];
if(debt<=0)smallest=min(smallest,j);
if(debt>oo)break; // no way to repay
debt=max(0ll,debt);
}*/
int sum = 0;
for(int j=i;j>=smallest;j--){
__int128 t=1ll<<(j-smallest);
sum+=(__int128)vec[j]*t;
}
__int128 res=sum/X;
res=min(res,(__int128)(1ll<<(i-smallest+1))-1);
res-=(__int128)(1ll<<(i-smallest));
ans+=max(0ll,(int)res+1);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |