Submission #817766

#TimeUsernameProblemLanguageResultExecution timeMemory
817766Theo830Packing Biscuits (IOI20_biscuits)C++17
21 / 100
1076 ms61620 KiB
#include <bits/stdc++.h> using namespace std; #define f(i,a,b) for(int i = a;i < b;i++) #define ll long long #define ii pair<ll,ll> #define pb push_back #define F first #define S second #define iii pair<ll,ii> #include "biscuits.h" map<ii,ll>dp; ll a[65] = {0}; ll x; ll solve(ll extra,ll j){ if(j > 60){ return 1; } if(dp.count(ii(extra,j))){ return dp[{extra,j}]; } extra += a[j]; ll ans = solve(extra / 2,j+1); if(extra >= x){ ans += solve((extra - x) / 2,j+1); } extra -= a[j]; return dp[{extra,j}] = ans; } long long count_tastiness(long long X, vector<long long> A){ dp.clear(); x = X; ll k = A.size(); f(i,0,65){ a[i] = 0; } f(i,0,k){ a[i] = A[i]; } f(i,0,60){ if(a[i] > x){ ll posa = a[i] - x; if(posa % 2 == 1){ a[i] = x+1; posa--; } else{ a[i] = x; } a[i+1] += posa / 2; } } 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...