Relay
면접 대비시간 제한1초메모리 제한1024 MB
서로 다른 세 명을 골라 순서를 정해 A_i + max(B_i,B_j) + A_j + max(B_j,B_k) + A_k의 최솟값을 구한다. N은 200,000까지 주어진다.
문제
There are members in the track club of JOI High School, numbered from to . For the member (), the time of the 100 m sprint is msec, and the ability of controlling the baton is .
The track club will participate in a national contest for the 300 m relay. Three members will run in the 300 m relay. Each member will run for 100 m. A runner will pass the baton to the next runner. Precisely, if the first runner is the member (), the second runner is the member (), and the third runner is the member (), then the three members will run the relay in the following steps.
- The member runs for 100 m with a baton. It takes msec.
- The member gives a baton to the member . It takes msec.
- The member runs for 100 m with a baton. It takes msec.
- The member gives a baton to the member . It takes msec.
- The member runs for 100 m with a baton. It takes msec.
Therefore, the record for the 300 m relay is msec. Here is the largest value of and . Since you are the coach of the track club, you want to choose three distinct members for the relay and decide the order of the runners so that the record becomes minimum.
Write a program which, given information of the members of the track club, calculates the minimum possible record of the 300 m relay.
입력
Read the following data from the standard input. Given values are all integers.
출력
Write one line to the standard output. The output should contain an integer which is the minimum possible record of the 300 m relay counted by msec.
제한
- .
- ().
- ().