Submission #589514

# Submission time Handle Problem Language Result Execution time Memory
589514 2022-07-04T19:31:03 Z LucaIlie Packing Biscuits (IOI20_biscuits) C++17
9 / 100
1000 ms 340 KB
#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

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 time Memory Grader output
1 Correct 15 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 27 ms 300 KB Output is correct
5 Correct 6 ms 292 KB Output is correct
6 Correct 63 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 63 ms 212 KB Output is correct
9 Correct 11 ms 292 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 26 ms 300 KB Output is correct
13 Correct 14 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 212 KB Output is correct
2 Execution timed out 1082 ms 212 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 27 ms 300 KB Output is correct
5 Correct 6 ms 292 KB Output is correct
6 Correct 63 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 63 ms 212 KB Output is correct
9 Correct 11 ms 292 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 26 ms 300 KB Output is correct
13 Correct 14 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 15 ms 212 KB Output is correct
16 Execution timed out 1082 ms 212 KB Time limit exceeded
17 Halted 0 ms 0 KB -