解眾數和~
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
for (int n, sum; cin >> n; cout << sum << endl)
{
int *data = new int[n], *counts = new int[n], i, max;
for (counts[i = 0] = 1; i < n; cin >> data[i++]);
sort(data, data + n);
for (i = max = 1; i < n; ++i)
{
counts[i] = data[i-1] == data[i] ? counts[i-1] + 1 : 1;
if(max < counts[i])
{
max = counts[i];
}
}
for(i = sum = 0; i < n; ++i)
{
if(counts[i] == max)
{
sum += data[i];
}
}
delete data;
delete counts;
}
}