Submission #306362

#TimeUsernameProblemLanguageResultExecution timeMemory
306362lohachoPacking Biscuits (IOI20_biscuits)C++14
0 / 100
2 ms384 KiB
#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std;

using LL = long long;
const LL INF = (LL)1e9 + 7;
const LL NS = (LL)1e5 + 4;
LL dp[64], mxget[64];

LL count_tastiness(LL x, vector<LL> a) {
    memset(dp, 0, sizeof(dp));
    memset(mxget, 0, sizeof(mxget));
    for(LL i = 0; i < (LL)a.size(); ++i){
        mxget[i] = a[i];
        if(i) mxget[i] += mxget[i - 1] / 2;
    }
    for(LL i = 0; i < (LL)a.size(); ++i){
        if(mxget[i] >= x){
            LL need = max(0ll, x - a[i]) * 2;
            for(LL last = i - 1; last >= 0; --last){
                if(mxget[last] >= x + need){
                    if(last) dp[i] += dp[last - 1];
                    else dp[i] += 1;
                    need = max(0ll, need + x - a[last]) * 2;
                }
                else{
                    need = max(0ll, need - a[last]) * 2;
                }
            }
            if(!need) ++dp[i];
        }
        if(i) dp[i] += dp[i - 1];
        else dp[i] += 1;
    }
    return dp[(LL)a.size() - 1];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...