# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
315676 | Sorting | Packing Biscuits (IOI20_biscuits) | C++17 | 1049 ms | 101172 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;
ll x, k;
vector<ll> a;
ll count_tastiness(ll _x, vector<ll> _a){
x = _x, a = _a;
k = a.size();
vector<array<ll, 2>> curr, prev;
prev.push_back({0, 1});
for(int i = 0; i < k; ++i, swap(curr, prev)){
ll l = prev[0][0], r = prev.back()[0];
l += a[i], r += a[i];
if(l < x){
if(r >= x) l = 0;
else l = l / 2;
}
else l = (l - x) / 2;
r = r / 2;
curr.resize(r - l + 1);
for(int j = 0; j < r - l + 1; ++j)
curr[j] = {j + l, 0};
for(int j = 0; j < prev.size(); ++j){
ll t = prev[j][0] + a[i];
curr[t / 2 - l][1] += prev[j][1];
if(t >= x) curr[(t - x) / 2 - l][1] += prev[j][1];
}
}
ll ans = 0;
for(int i = 0; i < prev.size(); ++i)
ans += (prev[i][0] / x + 1) * prev[i][1];
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... |