# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029381 | XJP12 | 선물상자 (IOI15_boxes) | C++14 | 0 ms | 0 KiB |
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>
using namespace std;
typedef vector<int> vi;
int delivery(int n, int k, int l, vi positions){
if(k==1){
int ans=0;
for(int i=0; i<n; i++){
ans+=min(positions[i],n-positions[i])*2;
}
return ans;
}
if(k==n){
int x = (int)(lower_bound(positions.begin(), positions.end(), l/2) - positions.begin());
int y = (int)(upper_bound(positions.begin(), positions.end(), l/2) - positions.begin());
x--;
int ans=0;
ans+=positions[x]*2;
ans+=(n-positions[y])*2;
ans=min(l, ans);
return ans;
}
return 0;
}