psn • 1年前
#include <iostream>
#include <algorithm>
using namespace std;
int wd[1000000];
int main(void) {
int N, M;
cin >> N >> M;
if (N > 20 || N < 5 || M >= 1000 || M <= 5) {
printf("NULL");
return 0;
}
for (int i = 0, u; i < M; i++) {
cin >> u;
wd[u]++;
}
for (int i = 1, n, maxn = 0; i <= N; i++) {
for (int u = N; u >= 1; u--) {
if (wd[u] >= 0 && wd[u] >= maxn) {
maxn = wd[u];
n = u;
}
}
printf("%d %d %d\n", i, maxn, n);
wd[n] = -1;
maxn = 0;
}
return 0;
}
评论:
请先登录,才能进行评论