You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
665 B
C++
31 lines
665 B
C++
#include <cstdio>
|
|
#include <algorithm>
|
|
#include <vector>
|
|
#include <map>
|
|
using namespace std;
|
|
const int N = 2e5 + 10;
|
|
int a[N];
|
|
int main()
|
|
{
|
|
map<int, int> idx;
|
|
int n;
|
|
scanf("%d", &n);
|
|
for (int i = 1; i <= n; i++)
|
|
scanf("%d", a + i), idx[a[i]]++;
|
|
vector<int> v;
|
|
for (auto i : idx)v.push_back(i.second);
|
|
long long add = 1, ans = 0, tmp, ty = 1;
|
|
sort(v.begin(), v.end());
|
|
for (int i = 0; i < v.size(); i++)
|
|
for (; ty <= v[i]; ty++) {
|
|
add = ty;
|
|
tmp = add;
|
|
add *= 2;
|
|
for (int k = i + 1; k < v.size(); k++)
|
|
if (v[k] >= add)
|
|
tmp += add, add *= 2;
|
|
ans = max(ans, tmp);
|
|
}
|
|
printf("%lld", ans);
|
|
return 0;
|
|
} |