이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define INF 99999999999999
#define all(x) x.begin(),x.end()
typedef long long ll;
long long delivery(int N, int K, int L, int p[]) {
ll n=N;
vector<ll>v;
for(int i=0;i<n;i++)
v.pb(i);
ll ans=INF;
do
{
ll curr=min(p[v[0]],L-p[v[0]]);
ll count=K-1;
ll pos=p[v[0]];
for(int i=0;i<n-1;i++)
{
if(count==0)
{
curr+=min(pos,L-pos);
count=K;
pos=0;
}
count--;
if(abs(pos-p[v[i+1]]) >= min(p[v[i+1]],L-p[v[i+1]]) + min(pos,L-pos))
{
curr+=min(p[v[i+1]],L-p[v[i+1]]) + min(pos,L-pos);
pos=p[v[i+1]];
count=K-1;
}
else
{
curr+=abs(pos-p[v[i+1]]);
pos=p[v[i+1]];
}
}
curr+=min(pos , L - pos);
ans=min(ans,curr);
} while (next_permutation(all(v)));
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... |