Submission #1207949

#TimeUsernameProblemLanguageResultExecution timeMemory
1207949CyanmondPacking Biscuits (IOI20_biscuits)C++20
100 / 100
6 ms840 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; using ll = long long; long long count_tastiness(long long x, std::vector<long long> a) { for (int i = 0; i < int(a.size()); ++i) { if (a[i] > x + 1) { ll diff = a[i] - (x + 1); ll div = (diff + 1) / 2; a[i] -= div * 2; if (i == int(a.size()) - 1) { a.push_back(0); } a[i + 1] += div; } } a.push_back(0); reverse(a.begin(), a.end()); int n = int(a.size()); vector<ll> dp(n + 1, 0ll); dp[0] = 1; for (int i = 0; i < n; ++i) { // case 1: no dp[i + 1] += dp[i]; // case 2: yes if (a[i] >= x) { dp[i + 1] += dp[i]; continue; } ll lack = x; for (int j = i; j < n; ++j) { lack -= a[j]; if (lack <= 0) { dp[j + 1] += dp[i]; lack += x; } lack *= 2; if (lack > 5 * x) { break; } } } return dp[n]; }
#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...