제출 #303541

#제출 시각아이디문제언어결과실행 시간메모리
303541user202729비스킷 담기 (IOI20_biscuits)C++17
9 / 100
1095 ms4920 KiB
// moreflags=grader.cpp // naive solution (penultimate subtask) // ... I think that code is fast enough? No? #include "biscuits.h" #include<cstdint> #include<algorithm> #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<(int)a.size()-1; ++i){ /* for(auto y: all) std::cout<<((y-s)>>std::min(i, 62))<<' '; std::cout<<" << \n"; */ // optional subtract x if(all[0]-(double)x*std::round(std::pow(2., i))>=(double)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; } s-=a[i+1]<<(i+1); } int curQuotient=0; int64_t result{}; std::for_each(all.rbegin(), all.rend(), [&](auto y){ auto const val=(y-s)>>(a.size()-1); while((curQuotient+1)*x<=val) ++curQuotient; result+=curQuotient+1; }); return result; }
#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...