# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
560526 | AlperenT | Packing Biscuits (IOI20_biscuits) | C++17 | 1085 ms | 8844 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;
long long count_tastiness(long long x, vector<long long> arr){
vector<pair<long long, long long>> prv, cur;
while(!arr.empty() && arr.back() == 0) arr.pop_back();
cur.push_back({0, 1});
int k = 0;
vector<long long> prefixsum(arr.size());
prefixsum.back() = arr.back();
for(int i = prefixsum.size() - 1; i >= 0; i--) prefixsum[i] = prefixsum[i + 1] + arr[i];
while(true){
bool flag = false;
long long cnt = k < arr.size() ? arr[k] : 0, prefixcnt = k < arr.size() ? prefixsum[k] : 0;
for(auto i : cur) if(i.first / 2 + prefixcnt - x >= 0) flag = true;
if(flag){
prv.clear();
sort(cur.begin(), cur.end());
for(auto p : cur){
if(prv.empty() || (prv.back().first != p.first / 2)) prv.push_back({p.first / 2, p.second});
else prv.back().second += p.second;
}
cur.clear();
for(auto i : prv){
cur.push_back({i.first + cnt, i.second});
if(i.first + cnt - x >= 0) cur.push_back({i.first + cnt - x, i.second});
}
}
else break;
k++;
}
long long ans = 0;
for(auto p : cur) ans += p.second;
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... |