# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
306249 | qpwoeirut | Packing Biscuits (IOI20_biscuits) | C++17 | 2 ms | 384 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;
typedef long long ll;
long long count_tastiness(long long x, std::vector<long long> a) {
a.resize(128, 0);
//cerr << "a: "; for (int i=0; i<a.size(); ++i) cerr << a[i] << ' '; cerr << endl;
int add = 0;
for (int i=0; i<a.size(); ++i) {
a[i] += add;
add = max(0LL, (a[i] - x) >> 1);
a[i] -= add << 1;
}
//cerr << "a: "; for (int i=0; i<a.size(); ++i) cerr << a[i] << ' '; cerr << endl;
ll ans = 1;
for (int i=0; i<a.size(); ++i) {
if (a[i] >= x) ans <<= 1;
}
//cerr << "base: " << ans << endl;
int cur = 0;
for (int i=0; i<a.size(); ++i) {
if (a[i] > x) {
++cur;
a[i+1] += a[i] >> 1;
a[i] = 0;
}
else {
if (cur > 0) {
ans += ans >> cur;
}
cur = 0;
}
}
return ans;
}
/*
2
3 3
5 2 1
3 2
2 1 2
1
5 1
0 1 1 1 2
1
4 1
1 5 2 9
1
5 1
0 0 0 1 0
1
1 1
128
*/
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... |