Submission #619029

#TimeUsernameProblemLanguageResultExecution timeMemory
619029A_DBoxes with souvenirs (IOI15_boxes)C++14
0 / 100
1 ms340 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; const int N=1e7+10; long long pre[N]; long long suf[N]; deque<pair<long long,long long>> deq; long long delivery(int N, int K, int L, int p[]) { long long ans=1e18; deq.push_back({(int)0,(int)-1}); for(int i=0;i<N;i++){ if(deq[0].second+K<i)deq.pop_front(); long long h=p[i]; long long u=deq[0].first; u+=h; pre[i]=u+min(h,L-h); deq.push_back({pre[i],i}); } ans=pre[N-1]; deq.clear(); deq.push_back({L,N}); for(int i=N-1;i>=0;i--){ if(deq[0].second-K>i)deq.pop_front(); long long h=p[i]; long long u=deq[0].first; u+=(L-h); suf[i]=u+min(h,L-h); // for(auto x:deq)cout<<x.first<<" ";cout<<"\n"; deq.push_back({suf[i],i}); } ans=min(ans,suf[0]); for(int i=0;i<N-1;i++){ ans=min(ans,pre[i]+suf[i+1]); } // for(int i=0;i<N;i++)cout<<pre[i]<<" ";cout<<"\n"; // for(int i=0;i<N;i++)cout<<suf[i]<<" ";cout<<"\n"; return ans; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:19:24: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   19 | long long delivery(int N, int K, int L, int p[]) {
      |                    ~~~~^
boxes.cpp:10:11: note: shadowed declaration is here
   10 | const int N=1e7+10;
      |           ^
#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...