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"
using namespace std;
using ll=long long;
struct inter {
ll deb,fin,rep;
};
const ll MAX_VAL=62;
ll nbTas,ajout,pos;
ll val[MAX_VAL];
vector<inter> memo[MAX_VAL];
vector<inter> nouv,proch;
inter temp;
ll count_tastiness(ll x,vector<long long> a) {
nbTas=x;
for (ll i=0;i<MAX_VAL;i++) {
memo[i].clear();
if (i>=(ll)a.size()) {
val[i]=0;
}
else {
val[i]=a[i];
}
//cout<<val[i]<<" ";
}
for (ll i=0;i<MAX_VAL;i++) {
if (val[i]>nbTas) {
ajout=(val[i]-nbTas)/2;
val[i]-=2*ajout;
val[i+1]+=ajout;
}
}
memo[MAX_VAL-1].push_back({0,nbTas+2,1});
for (ll i=MAX_VAL-2;i>=0;i--) {
//cout<<i<<" : ";
nouv=memo[i+1];
proch.clear();
pos=0;
for (ll j=0;j<(ll)nouv.size();j++) {
nouv[j].deb*=2;
nouv[j].fin*=2;
}
for (auto k:nouv) {
//cout<<k.deb<<" "<<k.fin<<" "<<k.rep<<"\t";
if (k.fin<=nbTas) {
proch.push_back(k);
}
else {
if (k.deb<nbTas) {
proch.push_back({k.deb,nbTas,k.rep});
k.deb=nbTas;
}
while (k.deb<k.fin) {
while (nouv[pos].fin+nbTas<=k.deb) {
pos++;
}
temp={max(k.deb,nouv[pos].deb+nbTas),min(k.fin,nouv[pos].fin+nbTas),k.rep+nouv[pos].rep};
proch.push_back(temp);
k.deb=temp.fin;
}
}
}
for (auto k:proch) {
//cout<<k.deb<<" "<<k.fin<<" "<<k.rep<<"\t";
k.deb-=val[i];
k.fin-=val[i];
if (k.fin>0 and k.deb<nbTas+2) {
memo[i].push_back({max(k.deb,(ll)0),min(k.fin,nbTas+2),k.rep});
}
}
/*cout<<"\t";
for (auto k:memo[i]) {
cout<<k.deb<<" "<<k.fin<<" "<<k.rep<<"\t";
}
cout<<endl;*/
}
return memo[0][0].rep;
}
# | 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... |