제출 #430334

#제출 시각아이디문제언어결과실행 시간메모리
430334alireza_kaviani비스킷 담기 (IOI20_biscuits)C++17
0 / 100
39 ms412 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]; j = max(0ll , j - A[i]) * 2; dp[i][j] = solve(i - 1 , j) + solve(i - 1 , j + x); //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); A[i + 1] += (A[i] - val) / 2; A[i] = val; } 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...