# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303535 | user202729 | Packing Biscuits (IOI20_biscuits) | C++17 | 1135 ms | 1051336 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.
// moreflags=grader.cpp
// naive solution (penultimate subtask)
#include "biscuits.h"
#include<cstdint>
#include<vector>
#include<cmath>
#include<iostream>
long long count_tastiness(long long x, std::vector<long long> a) {
std::vector<int64_t> all{a[0]};
int64_t s=0;
for(int i=0;; ++i){
/*
for(auto y: all) std::cout<<((y-s)>>std::min(i, 62))<<' ';
std::cout<<" << \n";
*/
// optional subtract x
if(all[0]-x*std::round(std::pow(2., i))>=s){
// ^ check to avoid x<<i overflows int64_t (which is actually what happened to me in the contest)
for(int n=(int)all.size(), index=0; index<n;++index)
if(
all[index]-(x<<i)
>=s
)
all.push_back(all[index]-(x<<i));
else break;
}
if(i+1<(int)a.size())
s-=a[i+1]<<(i+1);
if(i==a.size()+62){ // +62 is actually a good idea, to avoid handling some special cases
// the total complexity remains about small+2e5 for that subtask
return (int)all.size();
}
}
}
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... |