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>
#pragma GCC optimize("fast-math")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
ll count_tastiness(ll x, vector<ll> a) {
int n = 60;
while(sz(a) < 60) a.pb(0);
for(int i = 0; i < n-1; i++) {
if(a[i] < x) continue;
a[i+1] += (a[i] - x)/2;
a[i] = x + ((a[i] - x)%2);
}
a[n-1] = min(a[n-1], x);
vector<ll> dp;
dp.pb(0);
ll to_add = 0, aux = x;
for(int i = 0; i < n; i++, aux *= 2) {
// (val + to_add)/2^i >= x
// val >= (x << i) - to_add
to_add += (a[i] << i);
ll val = to_add - aux;
if(aux > 1e18) break;
int m = sz(dp);
for(int j = 0; j < m and dp[j] <= val; j++) {
// dp[i][j] = guarda quantos números eu posso formar
dp.pb(aux + dp[j]);
}
}
return sz(dp);
}
# | 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... |