Submission #830689

#TimeUsernameProblemLanguageResultExecution timeMemory
830689drdilyorBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
1 ms300 KiB
#include<bits/stdc++.h> #include "boxes.h" using ll = long long; using namespace std; long long delivery(int n, int k, int len, int p[]) { int mid1 = len / 2; int mid2 = (len+1) / 2; ll res = 0; int li = -1, ri = n; for (int i =0; i < n; i++) { if (p[i] > mid1) break; if (i % k == k-1) { li = i; res += p[i] * 2; } } for (int i = 0; i < n; i++) { int j = n - i - 1; if (p[j] < mid2) break; if (i % k == k-1) { ri = j; res += (n - p[j]) * 2; } } const ll infl = 1e18; int cnt = ri - li - 1; if (cnt <= k) { res += min({len, p[li+1] * 2, (len - p[ri-1]) * 2}); } else { res += len + min({len, p[li + k + 1] * 2, (len - p[ri - k - 1]) * 2}); } return res; }

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:27:14: warning: unused variable 'infl' [-Wunused-variable]
   27 |     const ll infl = 1e18;
      |              ^~~~
#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...