Submission #421310

#TimeUsernameProblemLanguageResultExecution timeMemory
421310vkgainzPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; bool can_make(vector<long long> nums, long long x, long long val) { for(int i = 0; i < (int) nums.size(); i++) { if(val & (1LL << i)) { if(nums[i] < x) return false; nums[i] -= x; } if(i < (int) nums.size() - 1) nums[i + 1] += nums[i] / 2; } return true; } long long num(vector<long long> nums, long long x) { long long mx = (1LL << ((int) nums.size() - 1)); if(!can_make(nums, x, mx)) return mx - 1; for(int i = (int) nums.size() - 2; i >=0; i--) { if(can_make(nums, x, mx ^ (1LL << i))) mx ^= (1LL << i); } return mx; } long long count_tastiness(long long x, vector<long long> a) { long long ans = 1; int lst = 0; for(int i = 1; i < (int) a.size(); i++) { vector<long long> temp; for(int r = lst; r < i; r++) { temp.push_back(a[r]); } long long mx = num(temp, x); if(mx != (1LL << (int) temp.size()) - 1) ans *= (mx + 1), lst = i; } vector<long long> temp; for(int r = lst; r < (int) a.size(); r++) temp.push_back(a[r]); long long mx = num(temp, x); ans *= (mx + 1); 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...