Submission #589514

#TimeUsernameProblemLanguageResultExecution timeMemory
589514LucaIliePacking Biscuits (IOI20_biscuits)C++17
9 / 100
1082 ms340 KiB
#include "biscuits.h"
#include <bits/stdc++.h>

using namespace std;

vector <long long> biscuits;

long long countSolutions( int b, long long s, long long x ) {
    int solutions;

    if ( b == biscuits.size() )
        return 1;

    solutions = countSolutions( b + 1, (biscuits[b] + s) / 2, x );
    if ( biscuits[b] + s >= x )
        solutions += countSolutions( b + 1, (biscuits[b] + s - x) / 2, x );

    return solutions;
}

long long count_tastiness( long long x, vector <long long> a ) {
    const int k = 60;
    long long s;

    a.resize( k );
    biscuits.clear();

    s = 0;
    for ( int b = 0; b < k; b++ ) {
        a[b] += s;
        if ( a[b] > x ) {
            s = a[b] - x;
            a[b] = x + s % 2;
            s /= 2;
        } else
            s = 0;
        biscuits.push_back( a[b] );
    }

    return countSolutions( 0, 0, x );
}

Compilation message (stderr)

biscuits.cpp: In function 'long long int countSolutions(int, long long int, long long int)':
biscuits.cpp:11:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     if ( b == biscuits.size() )
      |          ~~^~~~~~~~~~~~~~~~~~
#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...