Submission #620623

#TimeUsernameProblemLanguageResultExecution timeMemory
6206238e7Packing Biscuits (IOI20_biscuits)C++17
33 / 100
1091 ms128680 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r){ while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 100005 #define pii pair<int, int> #define ff first #define ss second #include "biscuits.h" long long count_tastiness(long long x, std::vector<long long> a) { for (int i = 0;i < 60;i++) a.push_back(0); int k = a.size(); for (int i = 0;i < k-1;i++) { ll d = max(0LL, ((a[i] - x)/2)*2); a[i] -= d; a[i+1] += d/2; } vector<ll> cnt(2*x+2, 0); int n = 2*x+2; cnt[0] = 1; for (int i = 0;i < k;i++) { for (int j = n-1;j >= 0;j--) { if (j >= a[i]) cnt[j] = cnt[j-a[i]]; else cnt[j] = 0; } for (int j = 0;j < n;j++) { if (j >= x) cnt[j-x] += cnt[j]; } for (int j = 0;j < n;j++) { cnt[j] = (j*2 < n ? cnt[j*2] : 0) + (j*2+1 < n ? cnt[j*2+1] : 0); } //pary(cnt.begin(), cnt.end()); } ll ans = 0; for (int i = 0;i < n;i++) ans += cnt[i]; 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...