Submission #65328

#TimeUsernameProblemLanguageResultExecution timeMemory
65328daniel_02Boxes with souvenirs (IOI15_boxes)C++17
10 / 100
4 ms380 KiB
#include "boxes.h" #include <bits/stdc++.h> #define ll long long using namespace std; long long delivery(int N, int K, int L, int p[]) { long long ans; ans = 1LL * 1e18 + 7; ll cur = 0; for (int i = 0; i < N; i++) { for (int j = i; j >= 0; j -= K) { if (p[j] <= L / 2) cur += (p[j] * 2); else { if (j - K + 1 >= 0) { cur += min((L - p[j - K + 1]) * 2, L); } else { if (p[0] > L / 2) cur += min((L - p[0]) * 2, L); else cur += L; } } } for (int j = i + 1; j < N; j += K) { if (p[j] > L / 2) { cur += ((L - p[j]) * 2); } else { if (j + K - 1 < N) { cur += min(p[j + K - 1] * 2, L); } else { if (p[N - 1] <= L / 2) cur += min(p[N - 1] * 2, L); else cur += L; } } } ans = min(ans, cur); } 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...