Submission #303535

#TimeUsernameProblemLanguageResultExecution timeMemory
303535user202729Packing Biscuits (IOI20_biscuits)C++17
9 / 100
1135 ms1051336 KiB
// 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)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:34:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   if(i==a.size()+62){ // +62 is actually a good idea, to avoid handling some special cases
      |      ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...