Submission #431847

#TimeUsernameProblemLanguageResultExecution timeMemory
431847muhammad_hokimiyonBoxes with souvenirs (IOI15_boxes)C++14
10 / 100
1 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 = max(1, i - K + 1); j >= 1; j--){ if(i - j + 1 > K)break; long long cost = L; cost = min(cost, p[i] * 2); cost = min(cost, (L - p[j]) * 2); d[i] = min(d[i], d[j - 1] + cost); } } return d[N]; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:18:14: warning: variable 'go' set but not used [-Wunused-but-set-variable]
   18 |         auto go = [&](int i, int j) -> ll{
      |              ^~
#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...