Submission #947610

#TimeUsernameProblemLanguageResultExecution timeMemory
9476104QT0RBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms2396 KiB
#include <bits/stdc++.h> using namespace std; int pref[10000002]; int suf[10000002]; int delivery(int n, int k, int l, int positions[]){ for (int i = 0; i<k; i++)pref[i]=positions[i]; for (int i = k; i<n; i++)pref[i]=positions[i]+pref[i-k]; for (int i = n-1; i>n-k-1; i--)suf[i]=l-positions[i]; for (int i = n-k-1; i>=0; i--)suf[i]=l-positions[i]+suf[i+k]; int ans=suf[0]; for (int i = 0; i<n-1; i++)ans=min(ans,2*pref[i]+2*suf[i+1]); for (int i = 0; i<n-1; i++)ans=min(ans,2*pref[i]+l+2*(i+k<n ? suf[i+k] : suf[n-1])); 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...