이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include <stdio.h>
#include <stdlib.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
#define N 100100
ll n,k,m,ans,x,now1,now2,nn,a[N],b[N];
long long delivery(int NN, int K, int L, int ppp[]) {
nn=NN;
k=K;
for(ll i=1;i<=nn;++i){
x=ppp[i-1];
if(x<L-x)a[++n]=x;
else b[++m]=L-x;
}
sort(a+1,a+1+n);
sort(b+1,b+1+m);
now1=now2=0;
while(n-now1>=k){
now1=now1+k;
ans+=a[now1]*2;
}
while(m-now2>=k){
now2=now2+k;
ans+=b[now2]*2;
}
if(now1>=n&&now2>=m)return ans;
if(now1>=n)return ans+b[m]*2;
if(now2>=m)return ans+a[n]*2;
x=n-now1+m-now2;
if(x<=k){
ans+=min(a[n]*2+b[m]*2,1ll*L);
}
else{
ans+=min(min(1ll*L*2,a[n]*2+b[m]*2),min(a[now1+(x-k)]*2+m,b[now2+(x-k)]*2+m));
}
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... |