Submission #288984

#TimeUsernameProblemLanguageResultExecution timeMemory
288984user202729Boxes with souvenirs (IOI15_boxes)C++17
100 / 100
771 ms73000 KiB
// moreflags=grader.cpp // // 10 #include "boxes.h" #include<vector> #include<cstdint> #include<climits> #include<deque> long long delivery(int N, int K, int L, int p[]) { std::deque<std::pair<int, int64_t>> queue, queueAdd; queue.push_back({N, 0}); queueAdd.push_back({N, 2*p[N-1]}); for(auto index=N;;){ --index; int64_t curValue=INT64_MAX; for(auto pointer: {&queue, &queueAdd}){ auto& it=*pointer; while(it.back().first>index+K) it.pop_back(); } curValue=std::min(curValue, queue.back().second+ std::min(L, 2* (L-p[index]))); curValue=std::min(curValue, queueAdd.back().second); if(index==0) return curValue; auto const add=[&](auto& queue, int64_t value){ while(not queue.empty() and queue.front().second>=value) queue.pop_front(); queue.push_front({index, value}); }; add(queue, curValue); add(queueAdd, curValue+2*p[index-1]); } }

Compilation message (stderr)

boxes.cpp: In lambda function:
boxes.cpp:28:48: warning: declaration of 'queue' shadows a previous local [-Wshadow]
   28 |   auto const add=[&](auto& queue, int64_t value){
      |                                                ^
boxes.cpp:11:38: note: shadowed declaration is here
   11 |  std::deque<std::pair<int, int64_t>> queue, queueAdd;
      |                                      ^~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...