Submission #752478

#TimeUsernameProblemLanguageResultExecution timeMemory
752478phoebeBoxes with souvenirs (IOI15_boxes)C++17
100 / 100
541 ms269812 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; #define ll long long ll delivery(int n, int k, int l, int p[]){ ll cw[n], ccw[n]; for (int i = 0; i < n; i++){ if (i - k < 0) cw[i] = 0; else cw[i] = cw[i - k]; cw[i] += p[i] + min(p[i], l - p[i]); } for (int i = n - 1; i >= 0; i--){ if (i + k >= n) ccw[i] = 0; else ccw[i] = ccw[i + k]; ccw[i] += (l - p[i]) + min(p[i], l - p[i]); } // for (int i = 0; i < n; i++) cout << cw[i] << ' '; cout << endl; // for (int i = 0; i < n; i++) cout << ccw[i] << ' '; cout << endl; ll re = min(cw[n - 1], ccw[0]); for (int i = 1; i < n; i++){ re = min(re, cw[i - 1] + ccw[i]); // cout << i << ' ' << re << endl; } return re; }
#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...