Submission #622929

#TimeUsernameProblemLanguageResultExecution timeMemory
622929JeanBombeurPacking Biscuits (IOI20_biscuits)C++17
0 / 100
4 ms340 KiB
#include "biscuits.h" #include <iostream> #include <cstdio> using namespace std; // <|°_°|> // M. Broccoli const int NB_BITS = 60; long long DP[NB_BITS + 1]; long long Sum[NB_BITS]; long long count_tastiness(long long nbPacks, vector <long long> Biscuits) { for (int i = 0; i <= NB_BITS; i ++) { DP[i] = 1; } int sz = Biscuits.size(); Sum[0] = Biscuits[0]; for (int i = 1; i < sz; i ++) { Sum[i] = (Biscuits[i] << i) + Sum[i - 1]; } for (int i = sz; i <= NB_BITS; i ++) { Sum[i] = Sum[i - 1]; } for (int i = 1; i <= NB_BITS; i ++) { long long sum = 1LL << 60; for (int j = i - 1; j >= 0; j --) { sum = min(sum, Sum[j]); if (nbPacks <= (sum >> j)) DP[i] += DP[j], sum -= (nbPacks << j); } } return DP[NB_BITS]; }
#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...