This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "boxes.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
deque<int> q;
ll delivery(int N, int K, int L, int p[])
{
for (int i = 0; i < N; i++)
{
if(p[i] == 0) continue;
q.push_back(p[i]);
}
ll ans = 0;
while(!q.empty()){
K = min(K, int(q.size()));
int d1 = q[K - 1];
int d2 = L - q[q.size() - K];
if(d1 > L / 2) d1 = L;
else d1 *= 2;
if(d2 > L / 2) d2 = L;
else d2 *= 2;
if(d1 <= d2){
for (int i = 0; i < K; i++)
{
q.pop_front();
}
ans += d1;
}
else{
for (int i = 0; i < K; i++)
{
q.pop_back();
}
ans += d2;
}
}
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... |