CF1642B.Power Walking

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Sam is a kindergartener, and there are nn children in his group. He decided to create a team with some of his children to play "brawl:go 2".

Sam has nn power-ups, the ii-th has type aia_i. A child's strength is equal to the number of different types among power-ups he has.

For a team of size kk, Sam will distribute all nn power-ups to kk children in such a way that each of the kk children receives at least one power-up, and each power-up is given to someone.

For each integer kk from 11 to nn, find the minimum sum of strengths of a team of kk children Sam can get.

山姆是一名幼儿园小朋友,他所在的小组共有 nn 名儿童。他决定从这些儿童中组建一支队伍来玩“大乱斗:围棋2”。

山姆拥有 nn 个增益道具,其中第 ii 个道具的类型为 aia_i。一名儿童的力量值等于他所拥有的增益道具中不同种类的数量。

对于一支大小为 kk 的队伍,山姆会将全部 nn 个增益道具分发给这 kk 名儿童,使得每名儿童至少获得一个道具,且每个道具恰好分配给一名儿童。

对每个从 11 到 nn 的整数 kk,求出山姆所能得到的、由 kk 名儿童组成的队伍的力量值总和的最小可能值。

输入格式

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤3⋅1051 \le t \le 3 \cdot 10^5) — the number of test cases. Description of the test cases follows.

The first line of each test case contains a single integer nn (1≤n≤3⋅1051 \le n \le 3 \cdot 10^5).

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9) — types of Sam's power-ups.

It is guaranteed that the sum of nn over all test cases does not exceed 3⋅1053 \cdot 10^5.

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤3⋅1051 \le t \le 3 \cdot 10^5),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤3⋅1051 \le n \le 3 \cdot 10^5)。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \le a_i \le 10^9),表示 Sam 的增益道具的类型。

保证所有测试用例的 nn 值之和不超过 3⋅1053 \cdot 10^5。

输出格式

For every test case print nn integers.

The kk-th integer should be equal to the minimum sum of strengths of children in the team of size kk that Sam can get.

对每个测试用例,输出 nn 个整数。

其中第 kk 个整数应等于 Sam 能够组成的大小为 kk 的队伍中,队员力量值之和的最小值。

输入输出样例

  • 输入#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,2k = 1: {1, 1, 2}
  • k=2:1,1,2k = 2: {1, 1}, {2}
  • k=3:1,1,2k = 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,5k = 1: {1, 2, 2, 2, 4, 5}
  • k=2:2,2,2,4,5,1k = 2: {2, 2, 2, 4, 5}, {1}
  • k=3:2,2,2,5,1,4k = 3: {2, 2, 2, 5}, {1}, {4}
  • k=4:2,2,2,1,4,5k = 4: {2, 2, 2}, {1}, {4}, {5}
  • k=5:2,2,1,2,4,5k = 5: {2, 2}, {1}, {2}, {4}, {5}
  • k=6:1,2,2,2,4,5k = 6: {1}, {2}, {2}, {2}, {4}, {5}

使第一组测试用例中强度总和最小的一种分配强化道具的方式:

  • k=1:1,1,2k = 1: {1, 1, 2}
  • k=2:1,1,2k = 2: {1, 1}, {2}
  • k=3:1,1,2k = 3: {1}, {1}, {2}

使第二组测试用例中强度总和最小的一种分配强化道具的方式:

  • k=1:1,2,2,2,4,5k = 1: {1, 2, 2, 2, 4, 5}
  • k=2:2,2,2,4,5,1k = 2: {2, 2, 2, 4, 5}, {1}
  • k=3:2,2,2,5,1,4k = 3: {2, 2, 2, 5}, {1}, {4}
  • k=4:2,2,2,1,4,5k = 4: {2, 2, 2}, {1}, {4}, {5}
  • k=5:2,2,1,2,4,5k = 5: {2, 2}, {1}, {2}, {4}, {5}
  • k=6:1,2,2,2,4,5k = 6: {1}, {2}, {2}, {2}, {4}, {5}

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

首页