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>
using namespace std;
const int c=60;
long long dp[c+1], b[c+1], h, o=0, sum;
long long count_tastiness(long long x, vector<long long> a) {
while(a.size()<c) a.push_back(0);
b[0]=a[0], dp[0]=1;
for (int i=1; i<c; i++) b[i]=b[i-1]/2+a[i];
for (int i=1; i<=c; i++) {
dp[i]=dp[i-1];
if (b[i-1]>=x) {
h=max(o, x-a[i-1])*2, sum=0;
for (int j=i-2; j>=0; j--) {
if (b[j]>=x+h) sum+=dp[j], h=max(o, h+x-a[j])*2;
else h=max(o, h-a[j])*2;
}
if (!h) sum++;
dp[i]+=sum;
}
}
return dp[c];
}
# | 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... |