CF1642B.Power Walking
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Sam is a kindergartener, and there are n children in his group. He decided to create a team with some of his children to play "brawl:go 2".
Sam has n power-ups, the i-th has type ai. A child's strength is equal to the number of different types among power-ups he has.
For a team of size k, Sam will distribute all n power-ups to k children in such a way that each of the k children receives at least one power-up, and each power-up is given to someone.
For each integer k from 1 to n, find the minimum sum of strengths of a team of k children Sam can get.
山姆是一名幼儿园小朋友,他所在的小组共有 n 名儿童。他决定从这些儿童中组建一支队伍来玩“大乱斗:围棋2”。
山姆拥有 n 个增益道具,其中第 i 个道具的类型为 ai。一名儿童的力量值等于他所拥有的增益道具中不同种类的数量。
对于一支大小为 k 的队伍,山姆会将全部 n 个增益道具分发给这 k 名儿童,使得每名儿童至少获得一个道具,且每个道具恰好分配给一名儿童。
对每个从 1 到 n 的整数 k,求出山姆所能得到的、由 k 名儿童组成的队伍的力量值总和的最小可能值。
输入格式
Each test contains multiple test cases. The first line contains a single integer t (1≤t≤3⋅105) — the number of test cases. Description of the test cases follows.
The first line of each test case contains a single integer n (1≤n≤3⋅105).
The second line contains n integers a1,a2,…,an (1≤ai≤109) — types of Sam's power-ups.
It is guaranteed that the sum of n over all test cases does not exceed 3⋅105.
每个测试包含多个测试用例。第一行包含一个整数 t(1≤t≤3⋅105),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤3⋅105)。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109),表示 Sam 的增益道具的类型。
保证所有测试用例的 n 值之和不超过 3⋅105。
输出格式
For every test case print n integers.
The k-th integer should be equal to the minimum sum of strengths of children in the team of size k that Sam can get.
对每个测试用例,输出 n 个整数。
其中第 k 个整数应等于 Sam 能够组成的大小为 k 的队伍中,队员力量值之和的最小值。
输入输出样例
输入#1
2 3 1 1 2 6 5 1 2 2 2 4
输出#1
2 2 3 4 4 4 4 5 6
说明/提示
One of the ways to give power-ups to minimise the sum of strengths in the first test case:
- k=1:1,1,2
- k=2:1,1,2
- k=3:1,1,2
One of the ways to give power-ups to minimise the sum of strengths in the second test case:
- k=1:1,2,2,2,4,5
- k=2:2,2,2,4,5,1
- k=3:2,2,2,5,1,4
- k=4:2,2,2,1,4,5
- k=5:2,2,1,2,4,5
- k=6:1,2,2,2,4,5
使第一组测试用例中强度总和最小的一种分配强化道具的方式:
- k=1:1,1,2
- k=2:1,1,2
- k=3:1,1,2
使第二组测试用例中强度总和最小的一种分配强化道具的方式:
- k=1:1,2,2,2,4,5
- k=2:2,2,2,4,5,1
- k=3:2,2,2,5,1,4
- k=4:2,2,2,1,4,5
- k=5:2,2,1,2,4,5
- k=6:1,2,2,2,4,5
输入解题思路,AI测评打分。不知道怎么写?