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

18459번 - Best Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB86403553.030%

문제

You are given the degree sequence of a tree (degrees of all its vertices, in arbitrary order).

Among all trees with the given degree sequence, find a tree with the largest maximum matching.

입력

The first line of input contains one integer t (1 ≤ t ≤ 100 000): the number of testcases.

Next lines contain t descriptions of a test case.

The first line of each test case contains one integer n (2 ≤ n ≤ 200 000): the number of vertices.

The next line contains n integers d1, d2, . . . , dn (1 ≤ di ≤ n − 1), the degree sequence of a tree.

It is guaranteed that Σdi = 2(n − 1) and that there is at least one tree with the given degree sequence.

Also, it is guaranteed that the total sum of n in all test cases is at most 200 000.

출력

For each test case, print one integer: the largest maximum matching among all trees with the given degree sequence.

제한

예제 입력 1

2
10
1 1 2 2 2 2 2 2 2 2
5
4 1 1 1 1

예제 출력 1

5
1

힌트

In the first test case, you can construct a path with 10 vertices, it will have the same degree sequence and the largest possible maximum matching.

In the second test case, the only possible tree is a star (one vertex connected with all others), and the largest matching for it is 1.

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 3: 300iq Petrozavodsk Contest III B번

  • 문제를 만든 사람: 300iq
(追記) (追記ここまで)

출처

대학교 대회

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

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