|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초 (추가 시간 없음)||512 MB||0||0||0||0.000%|
Dolly the delivery drone is out for a busy working day. It has to complete $n$ errands in a street where $\ell$ houses are lined up in a row, numbered in ascending order as $1, \dots, \ell$. The distance between adjacent houses is $1$. Each errand consists of picking up a package at some house $a$ and delivering it to another house $b$. Dolly can start with any errand, complete the errands in any order, and is able to carry an unlimited number of packages at the same time. Your job is to find the minimal total distance Dolly has to cover to complete all errands. The delivery route can start and finish at arbitrary locations along the street.
Figure E.1: Illustration of Sample Input 1. The shortest route is $2 \rightarrow 1 \rightarrow 9 \rightarrow 4$ with length $14$.
The input consists of:
Output a single line with the minimal distance Dolly has to cover from picking up the first package until delivering the last package.
10 6 1 4 3 5 6 7 2 1 9 4 8 5
100 3 11 50 50 49 36 35