| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 59 | 15 | 11 | 35.484% |
Farmer John's N (1 ≤ N ≤ 10,000) cows (conveniently numbered 1..N) graze in a straight line in their pasture whose length is L+1 (N ≤ L ≤ 100,000) meters. Every morning, they place themselves at various unique integer locations along that line. FJ has observed that the cows produce more milk when the distance to the other grazing cows is maximized.
Always the enterprising farmer, FJ wants to maximize the distance between each and every pair of neighboring cows by moving the cows to the right or left, but always with integer inter-cow spacing and never changing their order on the line. He spends 1 minute to move a cow 1 meter. When he's finished, he knows that the distances between every adjacent pair of cows will be one of two integers: D or D+1.
Help FJ to calculate minimum time he needs to arrange the positions of the cows.
5 10 0 1 4 9 10
3