Submission #430382

#TimeUsernameProblemLanguageResultExecution timeMemory
430382alireza_kavianiPacking Biscuits (IOI20_biscuits)C++17
0 / 100
32 ms332 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define sep ' ' const int MAXN = 62; ll x , A[MAXN]; map<ll , ll> dp[MAXN]; ll solve(int i , ll j){ if(i == -1) return (j == 0); if(j >= 4 * x) return 0; if(dp[i].find(j) != dp[i].end()) return dp[i][j]; ll y = max(0ll , j - A[i]) * 2; dp[i][j] = solve(i - 1 , y) + solve(i - 1 , x + y); // cout << i << sep << j << sep << dp[i][j] << endl; return dp[i][j]; } ll count_tastiness(ll x, vector<ll> a) { ::x = x; int n = a.size(); for(int i = 0 ; i < n ; i++){ A[i] = a[i]; } for(int i = 0 ; i < MAXN ; i++){ dp[i] = map<ll , ll>(); } for(int i = 0 ; i + 1 < MAXN ; i++){ ll val = min(A[i] , A[i] % x + x); if(val % 2 != A[i] % 2) val++; A[i + 1] += (A[i] - val) / 2; A[i] = val; // cout << A[i] << sep; } // cout << sep << A[61] << endl; return solve(61 , 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...