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 <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn=1e7+5;
int n, k, l;
int a[maxn];
ll rijesi(vector < int > niz){
ll sol=l;
sol=min(sol, (ll)(l-niz[0])*2);
sol=min(sol, (ll)niz[niz.size()-1]*2);
for(int i=0; i<(int)niz.size()-1; i++){
sol=min(sol, (ll)niz[i]*2+(l-niz[i+1])*2);
}
return sol;
}
ll delivery(int x, int y, int z, int p[]) {
n=x;
k=y;
l=z;
sort(p, p+n);
for(int i=0; i<n; i++){
a[i]=p[i];
}
ll sol=0;
int pos;
vector < int > v;
ll curr;
for(int i=0; i<n; i++){
pos=i;
curr=0;
for(int j=0; j<n/k; j++){
for(int m=0; m<k; m++){
v.push_back(p[pos]);
pos=(pos+1)%n;
}
sort(v.begin(), v.end());
curr+=rijesi(v);
v.clear();
}
if(n%k){
for(int m=0; m<n%k; m++){
v.push_back(p[pos]);
pos=(pos+1)%n;
}
sort(v.begin(), v.end());
curr+=rijesi(v);
v.clear();
}
sol=max(sol, curr);
}
return sol;
}
# | 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... |