Submission #431827

#TimeUsernameProblemLanguageResultExecution timeMemory
431827muhammad_hokimiyonBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
3 ms204 KiB
#include "boxes.h" #include <bits/stdc++.h> #define fi first #define se second #define ll long long #define dl double using namespace std; ll delivery(int N, int K, int L, int P[]) { vector<ll> d(N + 1, 1e18); d[0] = 0; vector<ll> p(N + 1, 0); for(int i = 1; i <= N; i++)p[i] = P[i - 1]; sort(p.begin(), p.end()); auto go = [&](int i, int j) -> ll{ ll res = 1e18; res = abs(p[i] - p[j]); return min(res, L - res); }; for(int i = 1; i <= N; i++){ for(int j = i; j >= 1; j--){ if(i - j + 1 > K)break; d[i] = min(d[i], d[j - 1] + min(L * 1ll, go(0, i) + go(i, j) + go(j, 0))); } } return d[N]; }
#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...