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

33607번 - Amusement Park Rides 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 2048 MB2911933.333%

문제

Ivan, Dmitrii, and Pjotr are celebrating Ivan’s birthday at an amusement park with $n$ attractions. The $i$-th attraction operates at minutes $a_i , 2a_i , 3a_i , \dots$ (i.e., every $a_i$ minutes).

Each minute, the friends can either ride exactly one available attraction together or wait. Since the rides are very short, they can board another attraction the next minute. They may ride the attractions in any order.

They want to experience each ride exactly once before heading off to enjoy the birthday cake. What is the earliest time by which they can finish all $n$ attractions?

입력

Each test contains multiple test cases. The first line contains an integer $t$ (1ドル ≤ t ≤ 2000$) — the number of test cases. The descriptions of the $t$ test cases follow.

The first line contains an integer $n$ (1ドル ≤ n ≤ 2000$) — the number of attractions.

The second line contains $n$ integers $a_1, a_2, \dots , a_n$ (1ドル ≤ a_i ≤ 10^9 $) — the values determining when the various attractions operate.

It is guaranteed that the sum of $n$ over all test cases does not exceed 2000ドル$.

출력

For each test case, print the earliest time the three friends can finish all $n$ attractions.

제한

예제 입력 1

3
4
1 2 3 4
4
1 1 1 1
6
1 2 1 2 2 2

예제 출력 1

4
4
8

In the first test case, the three friends can ride the $i$-th attraction at the $i$-th minute. Since there are 4ドル$ attractions, they need 4ドル$ minutes to ride them all.

In the third test case, the three friends can ride the attractions in order at minutes 1ドル,ドル 2ドル,ドル 3ドル,ドル 4ドル,ドル 6ドル,ドル 8ドル$ respectively. Therefore, they can ride all attractions in 8ドル$ minutes. One can show that it is impossible to finish all the attractions earlier.

힌트

출처

ICPC > Regionals > Europe > European Championship > The 2025 ICPC European Championship K번

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

출처

대학교 대회

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

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