Submission #425599

#TimeUsernameProblemLanguageResultExecution timeMemory
425599muhammad_hokimiyonPacking Biscuits (IOI20_biscuits)C++14
0 / 100
41 ms332 KiB
#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std;

long long count_tastiness(long long x, std::vector<long long> a) {
        long long ans = 1;
        vector<vector<long long>> d(101, vector<long long>(2, 0ll));
        while((int)a.size() < 70)a.push_back(0ll);
        if(a[0] > 0)d[0][0] = 1,ans++;
        for(int i = 1; i < 61; i++){
                if(a[i] > 0){
                        for(int j = i - 1; j >= 0; j--){
                                d[i][0] += d[j][0] + d[j][1];
                        }
                        d[i][0]++;
                        ans += d[i][0];
                }
                for(int j = i - 1; j >= 0; j--){
                        long long x = 0;
                        for(int h = j + 1; h < i; h++)x += (1ll << h) * a[h];
                        if(a[j] > 0)x += (1ll << j) * (a[j] - 1);
                        if(x >= (1ll << i))d[i][1] += d[j][0];
                        if(a[j] > 0){
                                x += (1ll << j);
                        }
                        if(x >= (1ll << i))d[i][1] += d[j][1];
                }
                long long x = 0;
                for(int j = i - 1; j >= 0; j--)x += (1ll << j) * a[j];
                if(x >= (1ll << i))d[i][1]++;
                if(a[i] == 0)ans += d[i][1];
        }
        return ans;
}

#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...