芝士不拉丝 • 1年前
using namespace std; int pio[25]; int main() { int n, m, tmp, maxn, num; scanf("%d %d", &n, &m); if (n < 5 || n > 20 || m <= 5 || m >= 1000) {
printf("NULL");
return 0;
} for (int i = 0; i < m; i++) {
scanf("%d", &tmp);
if (tmp)pio[tmp - 1]++;
} for (int i = 0; i < n; i++) {
maxn = 0;
num = 21;
for (int j = 0; j < n; j++) {
if (maxn < pio[j]) {
maxn = pio[j];
num = j;
} else if (maxn == pio[j] && num > j)num = j;
}
printf("%d %d %d\n", i + 1, maxn, num + 1);
pio[num] = -1;
} return 0; }
评论:
请先登录,才能进行评论