1

噢莫加纳加加加  •  1个月前


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

struct node {
	int val;
	int num = 0;
} res[10010];
int n, ans = 0, maxn = -1;

int h[10010] = {0};

int main() {
	//freopen("ix.in", "r", stdin);
	//freopen("ix.out", "w", stdout);
	cin >> n;
	int tot = n;
	for (int i = 1; i <= n; i++) {
		int high;
		cin >> high;
		if (high > maxn) {
			maxn = high;
		}
		h[high]++;
	}
	int cnt = 1;
	for (int i = 1; i <= maxn; i++) {
		if (h[i] > 0) {
			res[cnt].val = i;
			res[cnt].num = h[i];
			cnt++;
		}

	}
	while (tot != 0) {

		for (int i = 1; i <= cnt; i++) {
			if (res[i].num > 0) {
				tot--;
				res[i].num--;
			}
		}
		ans++;
	}
	cout << ans;
	return 0;
}

评论:

请先登录,才能进行评论