codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1393C.md (2565B)


      1 Source: https://codeforces.com/problemset/problem/1393/C
      2 
      3 C. Pinkie Pie Eats Patty-cakes
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 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!
     26 
     27 Pinkie Pie is going to buy more bags of patty-cakes so she asks you to solve this problem for several bags!
     28 
     29 Input
     30 
     31 The first line contains a single integer $T$ ($1 \le T \le 100$): the number of bags for which you need to solve the problem.
     32 
     33 The first line of each bag description contains a single integer $n$ ($2 \le n \le 10^5$): the number of patty-cakes in it. The second line of the bag description contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \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.
     34 
     35 It is guaranteed that the sum of $n$ over all bags does not exceed $10^5$.
     36 
     37 Output
     38 
     39 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.
     40 
     41 Example
     42 
     43 Input
     44 
     45 ```
     46 4
     47 7
     48 1 7 1 6 4 4 6
     49 8
     50 1 1 4 6 4 6 4 7
     51 3
     52 3 3 3
     53 6
     54 2 5 2 3 1 4
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 3
     61 2
     62 0
     63 4
     64 ```
     65 
     66 Note
     67 
     68 For the first bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): $1$, $6$, $4$, $7$, $1$, $6$, $4$ (in this way, the minimum distance is equal to $3$).
     69 
     70 For the second bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): $1$, $4$, $6$, $7$, $4$, $1$, $6$, $4$ (in this way, the minimum distance is equal to $2$).