Submission #413096

#TimeUsernameProblemLanguageResultExecution timeMemory
413096atoizPacking Biscuits (IOI20_biscuits)C++14
12 / 100
18 ms1184 KiB
#include "biscuits.h" #include <numeric> #include <cstdio> long long count_tastiness(long long x, std::vector<long long> a) { int k = (int) a.size(); std::vector<long long> dp(k + 1); dp[0] = 1; for (int i = 0; i < k; ++i) { std::vector<int> digit(i); long long cur = 0; for (int j = 0; j < i; ++j) { cur += a[j]; digit[j] = (cur & 1); cur /= 2; } cur += a[i]; dp[i + 1] = dp[i]; if (cur < x) { continue; } if (i < k - 1 && cur >= 2 * x) { dp[i + 1] *= 2; continue; } // fprintf(stderr, "i = %d, cur = %lld\n", i, cur); dp[i + 1] *= (cur / x); ++dp[i + 1]; cur %= x; for (int j = i - 1; j >= 0; --j) { cur = cur * 2 + digit[j]; if (cur >= x) { dp[i + 1] += dp[j]; cur -= x; } } } // for (int i = 0; i <= k; ++i) { // fprintf(stderr, "dp[1 << %d == %lld] = %lld\n", i, 1ll << i, dp[i]); // } return dp[k]; }
#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...