(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #430393

#TimeUsernameProblemLanguageResultExecution timeMemory
430393alireza_kavianiPacking Biscuits (IOI20_biscuits)C++17
100 / 100
349 ms1348 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 < MAXN ; i++){ dp[i] = map<ll , ll>(); A[i] = 0; } for(int i = 0 ; i < n ; i++){ A[i] = a[i]; } 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...