Submission #672764

#TimeUsernameProblemLanguageResultExecution timeMemory
672764tbzardPacking Biscuits (IOI20_biscuits)C++14
42 / 100
84 ms67140 KiB
#include <bits/stdc++.h> using namespace std; long long dp[210][20010]; long long count_tastiness(long long x, vector<long long> a){ memset(dp, 0, sizeof(dp)); vector<long long> b, c; long long sum = 0; for(int i=0;i<(int)a.size();i++){ sum += a[i]; if(sum > x) b.push_back(x), sum -= x; else b.push_back(sum), sum = 0; c.push_back(sum%2); sum /= 2; } while(sum > 0){ if(sum > x) b.push_back(x), sum -= x; else b.push_back(sum), sum = 0; c.push_back(sum%2); sum /= 2; } b.push_back(0); c.push_back(0); dp[0][0] = 1; for(int i=0;i<(int)b.size();i++){ for(int j=0;j<=20003;j++){ if(dp[i][j]){ dp[i+1][(j+b[i]+c[i])/2] += dp[i][j]; if(j+b[i] >= x) dp[i+1][(j+b[i]+c[i]-x)/2] += dp[i][j]; } } } long long ans = 0; for(int j=0;j<=20003;j++){ ans += dp[(int)b.size()][j]; } return ans; }
#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...