Submission #949079

#TimeUsernameProblemLanguageResultExecution timeMemory
949079irmuunBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
540 ms293976 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() ll delivery(int N,int K,int L,int pos[]){ ll pre[N+5],suf[N+5],ans=1e18; suf[N]=0; for(int i=0;i<K;i++){ pre[i]=pos[i]; } for(int i=K;i<N;i++){ pre[i]=pre[i-K]+pos[i]; } for(int i=N-1;i>=N-K;i--){ suf[i]=L-pos[i]; } for(int i=N-K-1;i>=0;i--){ suf[i]=suf[i+K]+(L-pos[i]); } ans=min(ans,suf[0]*2); for(int i=0;i<N;i++){ ans=min(ans,pre[i]*2+suf[i+1]*2); } ans=min(ans,suf[K]*2+L); for(int i=K;i<=N;i++){ ans=min(ans,pre[i-K]*2+suf[i+1]*2+L); } return ans; }
#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...