Submission #305767

#TimeUsernameProblemLanguageResultExecution timeMemory
305767arthurconmyPacking Biscuits (IOI20_biscuits)C++14
42 / 100
367 ms64760 KiB
#ifndef ARTHUR_LOCAL #include "biscuits.h" #endif #include <bits/stdc++.h> using namespace std; using ll = long long; #define len(x) int((x).size()) ll dp[101][40001]; ll count_tastiness(ll x, vector<ll> A) { // cout << len(A) << " " << (1<<(len(A))) << endl; for(int i=0; i<101; i++) { for(int j=0; j<40001; j++) { dp[i][j]=0LL; } } while(len(A) <= 100) A.push_back(0LL); for(int i=0; i<len(A); i++) { if(A[i] > x) { ll pass_up = ll((A[i]-x)/2LL); A[i] -= 2LL*pass_up; A[i+1] += pass_up; } } // for(int i=0; i<20; i++) cout << A[i] << " "; // cout << endl; dp[0][0] = 1; for(int b=0; b<=99; b++) { // transition up from dp[b] using 1<<b // case 1: don't add the zero for(int i=0; i<=40000; i++) { // if(dp[b][i] != 0) cout << b << " " << i << " " << dp[b][i] << endl; dp[b+1][ll(ll(i)/2LL) + A[b]] += dp[b][i]; // if(dp[b+1][int(i/2) + A[b]]) } for(int i=0; i<=40000; i++) { if(A[b] + ll(ll(i)/2LL) >= x) { dp[b+1][ll(ll(i)/2LL) + A[b] - x] += dp[b][i]; } } } ll ans=0LL; for(int i=0; i<=40000; i++) { ans += dp[100][i]; } return ans; } #ifdef ARTHUR_LOCAL int main() { cout << count_tastiness(1, {1,1,1,3,3,3,2,1,1}) << endl; // count_tastiness(10001, {10000}) << endl; // count_tastiness(1, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}) << endl; } #endif
#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...