2412: 【普及-】【P1271】选举学生会

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:10 解决:9

题目描述

学校正在选举学生会成员,有 lns="http://www.w3.org/1998/Math/MathML">(999) 名候选人,每名候选人编号分别从 1 到 lns="http://www.w3.org/1998/Math/MathML">,现在收集到了 lns="http://www.w3.org/1998/Math/MathML">(<=2000000) 张选票,每张选票都写了一个候选人编号。现在想把这些堆积如山的选票按照投票数字从小到大排序。

输入

输入 lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML"> 以及 lns="http://www.w3.org/1998/Math/MathML"> 个选票上的数字。

输出

求出排序后的选票编号。

样例输入 复制

5 10
2 5 2 2 5 2 2 2 1 2

样例输出 复制

1 2 2 2 2 2 2 2 5 5

提示


#include<bits/stdc++.h>
using namespace std;
int a[1010]={0},n,m,tmp;

int main(){
    cin>>n>>m;
    for (int i=0;i<m;i++) {
    	cin>>tmp;
    	a[tmp]++;
	}
	for (int i=1;i<=n;i++) 
		for (int j=0;j<a[i];j++)
		    cout<<i<<' ';
	cout<<endl;
	return 0;
}