This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
while((int) a.size() < 62) a.push_back(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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |