Submission #1175544

#TimeUsernameProblemLanguageResultExecution timeMemory
1175544hyakupPacking Biscuits (IOI20_biscuits)C++20
0 / 100
1 ms328 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define ll long long ll count_tastiness( ll x, vector<ll> a ){ int n = 4; while( (int)a.size() < n ) a.push_back(0); for( int i = 0; i < n; i++ ){ if( a[i] >= x ){ int aux = (a[i] - x)/2; a[i + 1] += aux; a[i] -= 2*aux; } } // // cout << "a "; // for( int x : a ) cout << x << " "; // cout << endl; int max_shift = __builtin_clzll(x); function<ll( int, int, ll, ll )> solve = [&]( int i, int j, ll remain, ll num ){ if( i < 0 ){ return 1LL; } // cout << "estado " << i << " " << j << " " << remain << endl; ll resp = solve(i - 1, j, remain, num); if( i >= max_shift ) return resp; ll goal = (x<<i); if( j > i ){ j = i; remain = a[i]; } if( (remain<<j) >= goal ){ int qtd = (goal>>j); remain -= qtd; ll aux = solve( i - 1, j, remain, num + (1<<i) ); // cout << "1 " << resp + aux << endl; return resp + aux; } goal -= (remain<<j); j--; while( j >= 0 ){ if( (a[j]<<j) >= goal ){ int qtd = (goal>>j); remain = a[j] - qtd; ll aux = solve( i - 1, j, remain, num + (1<<i) ); // cout << "2 " << resp + aux << endl; return resp + aux; } goal -= (a[j]<<j); j--; } // cout << "3 " << resp << endl; return resp; }; return solve( n - 1, n - 1, a[n - 1], 0 ); }
#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...