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

19227번 - Just Arrange the Icons 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB49292967.442%

문제

BerPhone X is almost ready for release with $n$ applications being preinstalled on the phone. A category of an application characterizes a genre or a theme of this application (like "game", "business", or "education"). The categories are given as integers between 1ドル$ and $n,ドル inclusive; the $i$-th application has category $c_i$.

You can choose $m$ --- the number of screens and $s$ --- the size of each screen. You need to fit all $n$ icons of the applications (one icon representing one application) meeting the following requirements:

  • On each screen, all the icons must belong to applications of the same category (but different screens can contain icons of applications of the same category);
  • Each screen must be either completely filled with icons (the number of icons on the screen is equal to $s$) or almost filled with icons (the number of icons is equal to $s-1$).

Your task is to find the minimal possible number of screens $m$.

입력

The first line contains an integer $t$ (1ドル \le t \le 10,000円$) --- the number of test cases in the input. Then $t$ test cases follow.

The first line of each test case contains an integer $n$ (1ドル \le n \le 2\cdot10^6$) --- the number of the icons. The second line contains $n$ integers $c_1, c_2, \dots, c_n$ (1ドル \le c_i \le n$), where $c_i$ is the category of the $i$-th application.

It is guaranteed that the sum of the values of $n$ for all test cases in the input does not exceed 2ドル\cdot10^6$.

출력

Print $t$ integers --- the answers to the given test cases in the order they follow in the input. The answer to a test case is an integer $m$ --- the minimum number of screens on which all $n$ icons can be placed satisfying the given requirements.

제한

예제 입력 1

3
11
1 5 1 5 1 5 1 1 1 1 5
6
1 2 2 2 2 1
5
4 3 3 1 2

예제 출력 1

3
3
4

노트

In the first test case of the example, all the icons can be placed on three screens of size 4ドル$: a screen with 4ドル$ icons of the category 1ドル,ドル a screen with 3ドル$ icons of the category 1ドル,ドル and a screen with 4ドル$ icons of the category 5ドル$.

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > Northern Eurasia Finals 2019 J번

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

출처

대학교 대회

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

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