Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <set>
- using namespace std;
- int main()
- {
- long long n, m;
- long long res=0;
- map<int, int> mapp;
- cin >> n;
- int ll;
- for (int i=0; i<n; i++){
- cin >> ll;
- mapp[ll]++;
- }
- bool b;
- int prev;
- set<int> sett;
- while (true){
- b = false;
- if (mapp.size()>0){
- for (auto &mm:mapp){
- res++;
- mm.second--;
- if (mm.second==0)
- sett.insert(mm.first);
- b = true;
- }
- for (auto &ss:sett)
- mapp.erase(ss);
- }
- res--;
- if (!b)
- break;
- }
- res++;
- cout << res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement