Logo
(追記) (追記ここまで)

9559번 - Circleland 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB100393546.667%

문제

You are visiting circleland, and you have long waited to visit their famous art exhibition. The exhibition has N rooms arranged in a cycle. In every room, there are some artistic pieces. The rooms are named R1, R2, ..., RN . There are also N corridors, named C1, C2, ..., CN , of lengths L1, L2, ..., LN , respectively. Each corridor Ci connects the two rooms Ri and Ri+1, except CN which connects RN and R1. Thus, the whole exhibition forms a cycle. You can walk in both directions in every corridor.

There is a single entrance to the exhibition in room R1, but there are exits in every room. As there is nothing interesting to see in the corridors, you would like to spend the least effort walking through corridors in the exhibition. Compute the minimum total distance you need to walk in corridors such that you enter from the entrance, exit from any exit and visit all rooms.

입력

Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100). Next T lines contain the test cases, each on a single line.

Each case starts with an integer N, the number of rooms in the exhibition (2 ≤ N ≤ 100, 000), followed by N numbers, the lengths of the corridors, L1, L2, ..., LN , in this order (1 ≤ Li ≤ 1, 000, 000).

The sum of the lengths of all corridors will not exceed 1, 000, 000, 000.

출력

For each test case, output, on a single line, a single number representing the minimum total distance you have to walk in corridors such that you visit all rooms.

제한

예제 입력 1

2
5 1 1 1 1 1
7 100 15 20 42 33 15 24

예제 출력 1

4
149

힌트

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > 2011 Arab Collegiate Programming Contest C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /