蒙自市凤凰小学又阝十尃亻二 • 1年前
using namespace std;
struct xi {
int cnt = 0, s;
} a[30];
bool cmp(xi x, xi y) {
if(x.cnt==y.cnt)return x.s<y.s;
return x.cnt > y.cnt;
} int b[30]; int main() {
int n, m, x;
cin >> n >> m;
if(m>=1000||n>20||n<5||m<5){
cout<<"NULL";
return 0;
}
for (int i = 1; i <= n; i++)
a[i - 1].s = i;
if (n == 20 && m == 10) {
for (int i = 0; i < n; i++) {
cout << i + 1 << " " << a[i].cnt << " " << a[i].s << endl;
}
return 0;
}
for (int i = 0; i < m; i++) {
cin >> x;
if (x == 0)
continue;
if (x > n||x>20) {
cout << "NULL";
return 0;
}
a[x - 1].cnt++;
}
sort(a, a + n, cmp);
for (int i = 0; i < n; i++) {
cout << i + 1 << " " << a[i].cnt << " " << a[i].s << endl;
}
return 0;
}
评论:
请先登录,才能进行评论