Submission #744450

#TimeUsernameProblemLanguageResultExecution timeMemory
744450MODDIBoxes with souvenirs (IOI15_boxes)C++14
100 / 100
515 ms263448 KiB
#include <bits/stdc++.h> #include "boxes.h" #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vl vector<ll> using namespace std; long long delivery(int n, int k, int l, int p[]) { ll ans = 2e18; vl clockwise(n+5,0); for(ll i = 0;i < n;i++){ if(i < k){ clockwise[i + 1] = 2 * p[i]; }else{ clockwise[i + 1] = clockwise[i + 1 - k] + (2 * p[i]); } } vl anticlockwise(n+5, 0); for(ll i = n - 1;i >= 0;i--){ if(i >= n - k + 1){ anticlockwise[i + 1] = 2 * (l - p[i]); }else{ anticlockwise[i + 1] = anticlockwise[i + 1 + k] + (2 * (l - p[i])); } } for(ll i = 0;i <= n;i++){ ans = min(ans,clockwise[i] + anticlockwise[i + 1]); } for(ll i = 0;i <=n-k;i++){ ans = min(ans,clockwise[i] + anticlockwise[i + 1 + k] + 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...