#include "boxes.h"
#include <bits/stdc++.h>
#pragma GCC target("lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sp << " " <<
using namespace std;
int delivery(int32_t N, int32_t K, int32_t L, int32_t p[]) {
deque<int> pos;
for (int i = 0;i<N;i++) pos.push_back(p[i]);
int ans = 0;
while (pos.size() > K) {
if (pos[K-1] <= L-pos[pos.size()-K]) {
ans+=pos[K-1]*2;
for (int j = 0;j<K;j++) pos.pop_front();
}
else {
ans+=pos[pos.size()-K]*2;
for (int j = 0;j<K;j++) pos.pop_back();
}
}
ans+=min({(int)L,pos.back()*2,(L-pos.front())*2});
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |