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 <bits/stdc++.h>
#include "boxes.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
ll delivery(int n, int k, int L, int positions[]){
ll l=(ll)L;
if(k==1){
ll ans=0;
for(int i=0; i<n; i++){
ans+=min(positions[i],L-positions[i])*2;
}
return ans;
}
if(k==n){
vi pos;
set<ll> z;
for(int i=0; i<n; i++){
int size=(int)z.size();
z.insert(positions[i]);
if((int)z.size()!=size){
pos.push_back(positions[i]);
}
}
int x = (int)(lower_bound(pos.begin(), pos.end(), l/2) - pos.begin());
int y = (int)(upper_bound(pos.begin(), pos.end(), l/2) - pos.begin());
x--;
long long ans=0;
ans+=pos[x]*2;
ans+=(n-pos[y])*2;
ans=min(l, ans);
return ans;
}
return 0;
}
# | 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... |