思路有了,卡在输入上
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
unordered_map<int, int> hash;
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
hash[x]++;
}
int res = 0;
for (unordered_map<int, int>::iterator it = hash.begin(); it != hash.end(); ++it) {
int hat = it->first + 1, num = it->second +it->first;
int i = num / hat;
res += i * hat;
}
cout << res;
return 0;
}