Submission #828795

#TimeUsernameProblemLanguageResultExecution timeMemory
828795Abrar_Al_SamitPacking Biscuits (IOI20_biscuits)C++17
12 / 100
3 ms316 KiB
#include <bits/stdc++.h> #include "biscuits.h" using namespace std; int k; vector<long long>a; long long dp[125][2]; long long solve(int i, int j) { if(i>=k) return 1; long long &ret = dp[i][j]; if(ret!=-1) return ret; ret = 0; int cr = a[i] + j; if(!cr) ret = solve(i+1, 0); else { ret = solve(i+1, cr/2) + solve(i+1, (cr-1)/2); } return ret; } long long count_tastiness(long long x, vector<long long> A) { A.resize(122); k = A.size(); a = A; for(int i=0; i<k-1; ++i) { if(a[i]==0) continue; int rem = a[i] % 2; if(!rem) rem = 2; long long take = a[i] - rem; a[i] = rem; for(int j=1; j<60 && take; ++j) { if(i+j==k) break; if(take >> j & 1) { ++a[i + j]; take -= 1LL << j; } else if(!a[i + j]) { ++a[i + j]; take -= 1LL << j; if(take >> j & 1) { ++a[i + j]; take -= 1LL << j; } } } } memset(dp, -1, sizeof dp); return solve(0, 0); }
#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...