Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Cmoss9

Problemset: กองชาม

Language: cpp

Time: 0.017 second

Submitted On: 2025-06-07 15:06:03

#include <bits/stdc++.h>
using namespace std;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int,int>> arr;
    int count = 0;
    // number and amount
    for (int i = 0;i<n;i++) {
        int a;
        cin >> a;
        auto it = find_if(arr.begin(), arr.end(), [a](const pair<int, int>& rizz) {
            return rizz.first == a;
        });
        if (it == arr.end()) {
            arr.push_back(make_pair(a,1));
        } else {
            it->second++;
        }
    }
    sort(arr.begin(),arr.end(),[](const auto& a, const auto& b) {
        return a.first > b.first;
    });
    while (true) {
        bool allZero = true;
        for (auto& i : arr) {
            if (i.second > 0) {
                allZero = false;
                i.second--;
            }
        }
        if (!allZero) {
            count++;
        }
        if (allZero) {
            break;
        }
    }
    cout << count;
}