# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
661137 | evenvalue | Packing Biscuits (IOI20_biscuits) | C++17 | 1 ms | 560 KiB |
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"
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;
using int64 = long long;
using ld = long double;
constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;
constexpr int kBits = 60;
int64 calc(const vector<int64> &biscuits) {
int64 ans = 1;
for (int i = 0; i < biscuits.size(); i++) {
ans += (1LL << i) * biscuits[i];
}
return ans;
}
int64 count_tastiness(int64 x, vector<int64> biscuits) {
biscuits.push_back(0);
assert(x == 1);
vector<vector<int64>> segments = {{}};
const int n = (int) biscuits.size();
for (int64 i = 0, carry = 0; i < n; i++) {
biscuits[i] += carry;
carry = (biscuits[i] - 1) / 2;
if (biscuits[i] == 0) {
segments.emplace_back();
} else {
segments.back().push_back(biscuits[i] - carry * 2);
}
}
int64 ans = 1;
for (const auto &segment : segments) {
ans *= calc(segment);
}
return ans;
}
Compilation message (stderr)
# | 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... |