Submission #696333

#TimeUsernameProblemLanguageResultExecution timeMemory
696333garam1732Packing Biscuits (IOI20_biscuits)C++14
12 / 100
20 ms780 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef __int128 ii; ll dp[100]; ll solve(ll x, vector<ll> a, bool full) { if(a.empty()) return dp[0] = 1; ll z = *a.rbegin(); int sz = a.size(); a.pop_back(); if(full && dp[sz]) return dp[sz]; ll q = z/x, res = 0; res += (q+1)*solve(x, a, 1); if(z % x) { ii v = (ii)(x-z%x)*(1LL<<(sz-1)); for(int i = (int)a.size()-1; i >= 0; i--) { if(v == 0) break; else if(v >= (ii)a[i]*(1LL<<i)) { v -= (ii)a[i]*(1LL<<i); a.pop_back(); } else { a[i] -= v/(1LL<<i); break; } } if(v == 0) res += solve(x, a, 0); } if(full) dp[sz] = res; return res; } long long count_tastiness(long long x, std::vector<long long> a) { for(int i = 0; i <= a.size(); i++) { dp[i] = 0; for(int j = i+1; j < a.size(); j++) { if(a[i]/x >= (1LL<<(j-i))-1) { a[i] += a[j]*(1LL<<(j-i)); a[j] = 0; } } } return solve(x, a, 0); }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 0; i <= a.size(); i++) {
      |                 ~~^~~~~~~~~~~
biscuits.cpp:43:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int j = i+1; j < a.size(); j++) {
      |                          ~~^~~~~~~~~~
#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...