Submission #309041

#TimeUsernameProblemLanguageResultExecution timeMemory
309041Vimmer비스킷 담기 (IOI20_biscuits)C++14
44 / 100
13 ms896 KiB
#include <bits/stdc++.h>
#include "biscuits.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 100005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
//typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll f[150], b[150];

ll count_tastiness(ll x, vector<ll> a)
{
    while (sz(a) < 60) a.PB(0);

    reverse(all(a)); a.PB(0);
    reverse(all(a));

    for (int i = 0; i < sz(a); i++)
    {
        b[i] += a[i];

        b[i + 1] = b[i] / 2;
    }

    f[0] = 1;

    for (int i = 0; i < 60; i++)
        if (b[i] < x)
        {
            f[i + 1] = f[i];

            continue;
        }
        else
        {
            ll sm = 0, need = max(0ll, x - a[i]);

            for (int j = i - 1; j >= 0; j--)
            {
                need += need;

                if (b[j] < need + x) need = max(0ll, need - a[j]);
                  else {sm += f[j]; need = max(0ll, need + x - a[j]);}
            }

            if (need == 0) sm++;

            f[i + 1] = f[i] + sm;
        }

    return f[60];
}

//int main()
//{
//    iostream::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//
//    // freopen("1.in", "r", stdin); //freopen("fcolor.out", "w", stdout);
//
//    cout << count_tastiness(1, {18}) << endl;
//}
#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...