Submission #730268

#TimeUsernameProblemLanguageResultExecution timeMemory
730268danikoynovPacking Biscuits (IOI20_biscuits)C++14
9 / 100
1079 ms340 KiB
#include "biscuits.h"
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int n, b[100];
long long count_tastiness(long long x, vector<long long> a)
{
    a.resize(20);
    n = a.size();
    ll sum = 0;
    for (int i = 0; i < n; i ++)
    {
        sum += a[i] * ((ll)(1) << i);
    }

    ll ans = 0;
    for (ll d = 0; d <= sum; d ++)
    {
        for (int i = 0; i < 20; i ++)
            b[i] = a[i];

            bool tf = true;
        for (ll bit = 0; bit < 20; bit ++)
        {
            ///cout << bit << " : " << b[bit] << endl;
            if ((d & (1 << bit)) > 0)
            {
                ///cout << "yes" << endl;
                if (b[bit] < x)
                {
                    tf = false;
                    break;
                }
                b[bit] -= x;
            }
            b[bit + 1] = b[bit + 1] + b[bit] / 2;
        }
        ///cout << d << " " << tf << endl;
        if (tf)
            ans ++;
    }
    ///cout << ans << endl;

    return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:21:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   21 |         for (int i = 0; i < 20; i ++)
      |         ^~~
biscuits.cpp:24:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   24 |             bool tf = true;
      |             ^~~~
#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...