Submission #392219

#TimeUsernameProblemLanguageResultExecution timeMemory
392219johuthaPacking Biscuits (IOI20_biscuits)C++17
12 / 100
6 ms332 KiB
#include "biscuits.h" #include <iostream> #define int long long using namespace std; int count_tastiness(int x, vector<int> a) { vector<int> dpref(63); vector<int> vpref(63); vector<int> dp(62); a.resize(64); int v = 0; int pw = 1; int m = 60; for (int i = 0; i < m; i++, pw *= 2) { v += a[i]*pw; vpref[i] = v; int b = v - pw*x; int np = pw / 2; // cerr << "Starting " << i << ": " << v << " " << b << "\n"; for (int j = i - 1; j >= 0; j--, np /= 2) { b = min(b, vpref[j]); if (b >= np*x && vpref[j] >= np * x) { // cerr << " -> Take " << j << " (add " << 1 + dpref[j] << ") " << "\n"; b -= np*x; dp[i] += 1 + dpref[j]; } } if (b >= 0) dp[i]++; dpref[i + 1] = dpref[i] + dp[i]; // cerr << i << " " << dp[i] << " " << dpref[i] << "\n"; } return dpref[m] + 1; }
#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...