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 "biscuits.h"
#define int long long
using namespace std;
const int kmax = 65;
const int ymax = 1e5;
vector<int> getBinary(int n){
vector<int> bin(kmax);
int k = 0;
while (n > 0){
if (n % 2) bin[k] = 1;
k++;
n /= 2;
}
return bin;
}
bool possible(int x, int y, vector<int> avail){
vector<int> bin = getBinary(y);
for (int i = kmax-1; i >= 0; --i) {
bin[i] *= x;
}
for (int i = 0; i < kmax-1; ++i) {
if (bin[i] > avail[i]) return false;
avail[i] -= bin[i];
avail[i+1] += avail[i] / 2;
}
return true;
}
int count_tastiness(int x, vector<int> a) {
int ans = 0;
vector<int> avail(kmax);
for (int i = a.size()-1; i >= 0; --i) {
avail[i] = a[i];
}
for (int i = 0; i <= ymax; ++i) {
if (possible(x, i, avail)) ans++;
}
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... |