Submission #947612

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