1


小S有一个长度为\(n\)的序列,序列里每个元素是\([1,C]\)的整数。

现在,小S决定对这个序列进行排序,排序规则如下:

首先,按元素个数多少进行排序

如果元素个数相同,则哪个元素最先出现,哪个元素排在前面

请你帮小S排序。

输入格式
第一行两个整数\(N,C\)

接下来 \(1\) 行,\(N\)个整数表示这个序列。

输出格式
\(N\)个整数,表示答案。

样例1
input

5 2
2 1 2 1 2

output

2 2 2 1 1

样例2
input

9 3
1 3 3 3 2 2 2 1 1

output

1 1 1 3 3 3 2 2 2

数据范围
\(1≤N≤1000,1≤C≤1000\)

时间限制:1S

空间限制:256MB

模拟题。找到每个数出现的最前面的位置和出现次数,然后用sort就可以了。

#include
#include
using namespace std;
int n,c,cnt[1005],f[1005],a[1005];
bool cmp(int a,int b)
{
	if(cnt[a]!=cnt[b])
		return cnt[a]>cnt[b];
	return f[a]