CF1077E.Thematic Contests
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarp has prepared n competitive programming problems. The topic of the i-th problem is ai, and some problems' topics may coincide.
Polycarp has to host several thematic contests. All problems in each contest should have the same topic, and all contests should have pairwise distinct topics. He may not use all the problems. It is possible that there are no contests for some topics.
Polycarp wants to host competitions on consecutive days, one contest per day. Polycarp wants to host a set of contests in such a way that:
- number of problems in each contest is exactly twice as much as in the previous contest (one day ago), the first contest can contain arbitrary number of problems;
- the total number of problems in all the contests should be maximized.
Your task is to calculate the maximum number of problems in the set of thematic contests. Note, that you should not maximize the number of contests.
Polycarp 准备了 n 道编程竞赛题目。第 i 道题的主题为 ai,某些题目的主题可能相同。
Polycarp 需要举办若干场主题竞赛。每场竞赛中的所有题目必须具有相同主题,且各场竞赛的主题必须两两不同。他可以不使用全部题目。某些主题可能不举办任何竞赛。
Polycarp 计划在连续的若干天中每天举办一场竞赛。他希望以如下方式安排一组竞赛:
- 每场竞赛所含题目数量恰好是前一场(即前一天)竞赛的两倍;首场竞赛的题目数量可以任意;
- 所有竞赛的题目总数应尽可能大。
你的任务是计算这组主题竞赛所能包含的最大题目总数。注意:你不应最大化竞赛场数。
输入格式
The first line of the input contains one integer n (1≤n≤2⋅105) — the number of problems Polycarp has prepared.
The second line of the input contains n integers a1,a2,…,an (1≤ai≤109) where ai is the topic of the i-th problem.
输入的第一行包含一个整数 n(1≤n≤2⋅105)—— 表示 Polycarp 准备的问题数量。
输入的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109),其中 ai 表示第 i 个问题的主题。
输出格式
Print one integer — the maximum number of problems in the set of thematic contests.
输出一个整数——主题竞赛题目集合中题目的最大数量。
输入输出样例
输入#1
18 2 1 2 10 2 10 10 2 2 1 10 10 10 10 1 1 10 10
输出#1
14
输入#2
10 6 6 6 3 6 1000000000 3 3 6 6
输出#2
9
输入#3
3 1337 1337 1337
输出#3
3
说明/提示
In the first example the optimal sequence of contests is: 2 problems of the topic 1, 4 problems of the topic 2, 8 problems of the topic 10.
In the second example the optimal sequence of contests is: 3 problems of the topic 3, 6 problems of the topic 6.
In the third example you can take all the problems with the topic 1337 (the number of such problems is 3 so the answer is 3) and host a single contest.
在第一个例子中,最优的比赛序列是:主题 1 的 2 道题、主题 2 的 4 道题、主题 10 的 8 道题。
在第二个例子中,最优的比赛序列是:主题 3 的 3 道题、主题 6 的 6 道题。
在第三个例子中,你可以选取所有主题为 1337 的题目(此类题目共 3 道,因此答案为 3),并举办一场比赛。
输入解题思路,AI测评打分。不知道怎么写?