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 <bits/stdc++.h>
#include "biscuits.h"
//~ #include "grader.cpp"
using namespace std;
#define ll long long
int k;
ll x, dp[61][10001];
vector <ll> a;
ll solve(int idx, int p){
if(idx == k) return 1;
ll &ret = dp[idx][p];
if(ret != -1) return ret;
ret = 0;
int f = a[idx] + p;
ret += solve(idx + 1, f / 2);
if(f >= x){
ret += solve(idx + 1, (f - x) / 2);
}
return ret;
}
long long count_tastiness(long long X, vector<long long> A){
x = X;
a = A;
k = a.size();
memset(dp, -1, sizeof dp);
for(int i = 0 ; i < k ; i++){
if(a[i] <= x) continue;
int f = a[i] - x;
f -= f % 2;
a[i] -= f;
if(i + 1 < k) a[i + 1] += x / 2;
}
return solve(0, 0);
}
# | 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... |