CF1393C.Pinkie Pie Eats Patty-cakes

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling.

Pinkie Pie eats the patty-cakes one-by-one. She likes having fun so she decided not to simply eat the patty-cakes but to try not to eat the patty-cakes with the same filling way too often. To achieve this she wants the minimum distance between the eaten with the same filling to be the largest possible. Herein Pinkie Pie called the distance between two patty-cakes the number of eaten patty-cakes strictly between them.

Pinkie Pie can eat the patty-cakes in any order. She is impatient about eating all the patty-cakes up so she asks you to help her to count the greatest minimum distance between the eaten patty-cakes with the same filling amongst all possible orders of eating!

Pinkie Pie is going to buy more bags of patty-cakes so she asks you to solve this problem for several bags!

萍琪派买了一袋馅料各异的帕蒂蛋糕!但事实证明,并非所有帕蒂蛋糕的馅料都互不相同。换言之,这袋中包含若干个馅料相同的帕蒂蛋糕。

萍琪派会一个接一个地吃掉这些帕蒂蛋糕。她喜欢玩得开心,因此决定不简单地按顺序吃掉它们,而是尽量避免频繁地吃到相同馅料的帕蒂蛋糕。为实现这一目标,她希望:所有被吃掉的、馅料相同的两个帕蒂蛋糕之间的最小距离尽可能大。此处,萍琪派将两个帕蒂蛋糕之间的“距离”定义为:严格位于它们之间、已被吃掉的帕蒂蛋糕的数量。

萍琪派可以按任意顺序吃掉这些帕蒂蛋糕。由于她急着吃完所有蛋糕,因此请你帮她计算:在所有可能的进食顺序中,相同馅料的帕蒂蛋糕之间所能达到的最大最小距离是多少!

萍琪派打算购买更多袋帕蒂蛋糕,因此她请你为多袋蛋糕分别解决此问题!

输入格式

The first line contains a single integer TT (1≤T≤1001 \le T \le 100): the number of bags for which you need to solve the problem.

The first line of each bag description contains a single integer nn (2≤n≤1052 \le n \le 10^5): the number of patty-cakes in it. The second line of the bag description contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤n1 \le a_i \le n): the information of patty-cakes' fillings: same fillings are defined as same integers, different fillings are defined as different integers. It is guaranteed that each bag contains at least two patty-cakes with the same filling.

It is guaranteed that the sum of nn over all bags does not exceed 10510^5.

第一行包含一个整数 TT(1≤T≤1001 \le T \le 100):你需要解决该问题的袋子数量。

每个袋子描述的第一行包含一个整数 nn(2≤n≤1052 \le n \le 10^5):该袋中肉饼的数量。袋子描述的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤n1 \le a_i \le n):表示各肉饼的馅料信息;相同馅料用相同的整数表示,不同馅料用不同的整数表示。保证每个袋子中至少有两个肉饼具有相同的馅料。

保证所有袋子的 nn 值之和不超过 10510^5。

输出格式

For each bag print in separate line one single integer: the largest minimum distance between the eaten patty-cakes with the same filling amongst all possible orders of eating for that bag.

对于每个袋子,在单独的一行中输出一个整数:在该袋子所有可能的食用顺序中,相同馅料的已食用派蒂蛋糕之间最小距离的最大值。

输入输出样例

  • 输入#1

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

    输出#1

    3
    2
    0
    4

说明/提示

For the first bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): 11, 66, 44, 77, 11, 66, 44 (in this way, the minimum distance is equal to 33).

For the second bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): 11, 44, 66, 77, 44, 11, 66, 44 (in this way, the minimum distance is equal to 22).

对于第一个袋子,萍琪派可以按以下顺序(按馅料)吃小蛋糕:11、66、44、77、11、66、44(这样,最小间距等于 33)。

对于第二个袋子,萍琪派可以按以下顺序(按馅料)吃小蛋糕:11、44、66、77、44、11、66、44(这样,最小间距等于 22)。

输入解题思路,AI测评打分。不知道怎么写?

首页