Submission #834790

#TimeUsernameProblemLanguageResultExecution timeMemory
834790finn__비스킷 담기 (IOI20_biscuits)C++17
0 / 100
813 ms2097152 KiB
#include <bits/stdc++.h>

#include "biscuits.h"

using namespace std;
using L = long long;

constexpr size_t N = 61;

int64_t b[N], c[N], x;

int64_t f(int64_t n)
{
    size_t const j = __countl_zero(n);
    if (1LL << j == n && c[j] != -1)
        return c[j];
    size_t const i = __countl_zero(n - 1);
    int64_t ans = f(1LL << i) + f(min(n, (b[i]) / x + 1) - (1LL << i));
    if (1LL << j == n)
        c[j] = ans;
    return ans;
}

L count_tastiness(L x_, vector<L> a)
{
    x = x_;
    memset(b, 0, sizeof b);
    memset(c, 255, sizeof c);
    c[0] = 1;
    partial_sum(a.begin(), a.end(), b);
    return f(1LL << 60);
}
#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...