Submission #1031813

#TimeUsernameProblemLanguageResultExecution timeMemory
1031813hotboy2703Packing Biscuits (IOI20_biscuits)C++17
35 / 100
7 ms1284 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; using ll = long long; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL<<(i)) namespace trung{ ll dp[61]; ll req[61]; ll sum[61]; ll a[61]; } long long count_tastiness(long long x, std::vector<long long> A) { using namespace trung; for (ll i = 0;i < 60;i ++){ dp[i] = 0; req[i] = 0; } for (ll i = 0;i < sz(A);i ++)a[i] = A[i]; for (ll i = 0;i < 60;i ++){ sum[i] = a[i] * MASK(i); if (i)sum[i] += sum[i-1]; req[i] = (sum[i]/x)-MASK(i); } for (ll i = 0; i < 60;i ++){ ll cur = MASK(i+1)-1; for (ll j = i;j >= 0;j --){ if (BIT(cur,j)){ if (j==0)dp[i]++; else dp[i]+=dp[j-1]; cur -= MASK(j); cur = min(cur,req[j]); if (cur < 0){ break; } } if (j==0)dp[i]++; } } return dp[59]; }
#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...