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

9720번 - Sorting 다국어

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

문제

We have an array and we want to sort it in non-decreasing order. The only allowable operation is to move one element of the array into any other place (before all elements, after all elements or between any two adjacent elements). The cost of the single operation is equal to the value of the moved element. We want to minimize the total cost of sorting the array. You are to write a program that will find the minimum cost to sort such an array.

입력

First line of the input contains T the number of test cases. For each test case the first line contains an integer N (1 ≤ N ≤ 100). The second line contains N positive integers separated by spaces. These integers denote the array. Each of these integers is between 1 and 1000 inclusive.

출력

For each case, the output contains an integer denoting the minimum cost to sort the array.

제한

예제 입력 1

3
4
7 1 2 3
4
7 1 2 5
6
8 2 6 5 1 4

예제 출력 1

6
7
18

힌트

출처

ICPC > Regionals > Asia Pacific > Malaysia > Malaysia National Programming Contest > Al-Khawarizmi National Programming Contest 2011 H번

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

출처

대학교 대회

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

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