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;
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;
ll sum = 0;
while(sz(a) < 60) a.pb(0);
for(int i = 0; i < n; i++) sum += a[i] * (1LL<<i);
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);
// for(int i = 0; i < n; i++) cout << a[i] << " ";
// cout << endl;
unordered_map<ll,ll> dp[n+1];
dp[0][0] = 1;
for(int i = 0; i < n; i++) {
for(auto [j, qtd] : dp[i]) {
// dp[i][j] = guarda quantos números eu posso formar
dp[i+1][(j+a[i])/2] += qtd;
if(j+a[i] >= x) dp[i+1][(j+a[i]-x)/2] += qtd;
}
}
ll ans = 0;
for(auto [j, qtd] : dp[n]) ans += qtd;
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... |