Submission #133030

#TimeUsernameProblemLanguageResultExecution timeMemory
133030MAMBABoxes with souvenirs (IOI15_boxes)C++14
0 / 100
2 ms376 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define rep(i , j , k) for (int i = j; i < (int)k; i++) typedef long long ll; typedef vector<ll> vl; ll delivery(int N, int K, int Ll, int p[]) { sort(p , p + N); vl L(N) , R(N); rep(i , 0 , N) { L[i] = p[i]; if (i >= K) L[i] += L[i - K]; } for (int i = N - 1; ~i; i--) { R[i] = Ll - p[i]; if (i + K < N) R[i] += R[i + K]; } ll ans = 2 * L[N - 1] - max(0 , Ll - 2 * p[N - 1]); ans = min(ans , 2 * R[0] - max(0 , 2 * p[0] - Ll)); rep(i , 1 , N) ans = min(ans , 2 * (L[i - 1] + R[i]) - max(0 , max(Ll - 2 * p[i - 1] , 2 * p[i] - Ll))) ; 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...