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;
long long count_tastiness(long long x, std::vector<long long> a) {
int n=(int)a.size();
if(x<=10000){
vector<long long>dp(x*2+10),fake(x*2+10);
long long unnow=0;
for(int i=0;i<n;i++){
a[i]+=unnow;
if(a[i]>x){
unnow=a[i]-x;
unnow/=2;
a[i]-=unnow*2;
}else{
unnow=0;
}
//cout<<i<<" "<<a[i]<<endl;
}
dp[0]=1;
for(int i=0;i<n;i++){
for(int j=0;j<=x*2;j++){
fake[j/2+a[i]]+=dp[j];
if(j/2>=(x-a[i])){
fake[j/2-(x-a[i])]+=dp[j];
}
}
for(int j=0;j<=x*2;j++){
swap(dp[j],fake[j]);
fake[j]=0;
}
}
long long mainres=0;
for(int i=0;i<=x*2;i++){
mainres+=dp[i];
}
return mainres;
}else{
return 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... |