#include "boxes.h"
#include <bits/stdc++.h>
#define REP(v, i, j) for (int v = i; v != j; v++)
#define FORI(v) for (auto i : v)
#define FORJ(v) for (auto j : v)
#define OUT(v, a) \
FORI(v) \
cout << i << a;
#define OUTS(v, a, b) \
cout << v.size() << a; \
OUT(v, b)
#define in(a, n) \
REP(i, 0, n) \
cin >> a[i];
#define SORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define MEMSET(m) memset(m, -1, sizeof m)
#define pb push_back
#define fi first
#define se second
#define detachIO \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
using namespace std;
long long delivery(int N, int K, int L, int p[]) {
long long streak=0;
long long ans=0;
vector<long long> fw, bw;
REP(i,0,N){
ans+=p[i]*2;
if(p[i])fw.pb(p[i]*2),streak++;
}
SORT(fw);
FORI(fw)bw.pb(2*L-i);
SORT(bw);
REP(i,0,streak){
bw[i]=min<long long>(bw[i],L);
fw[i]=min<long long>(fw[i],L);
}
if(K < streak)REP(i,K,streak){
fw[i]+=fw[i-K];
bw[i]+=bw[i-K];
}
REP(i,0,streak-1){
ans=min(ans,fw[i]+bw[streak-2-i]);
}
ans=min(ans,bw[streak-1]);
ans=min(ans,fw[streak-1]);
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... |