#959
Silver III
SORT
시간 제한
1s
메모리 제한
32MB
제출
1
정답
1
맞힌 사람
1
정답 비율
100.0%

문제

Author: Luka Kalinovčić Mirko is a great code breaker. He knows any cipher in the world can be broken by frequency analysis. He has completely the wrong idea what frequency analysis is, however. He intercepted an enemy message. The message consists of N numbers, smaller than or equal to C Mirko belives freqency analysis consists of sorting this sequence so that more frequent numbers appear before less frequent ones. Formally, the sequence must be sorted so that given any two numbers X and Y , X appears before Y if the number of times X appears in the original sequence is larger than the number of time Y does. If the number of appearances is equal, the number whoes value appears sooner in the input should appear sooner in the sorted sequence. Help Mirko by creating a "frequency sorter".

입력

First line of input contains two integers, N (1 ≤ N ≤ 1 000), length of message, and C (1 ≤ C ≤ 1 000 000 000), the number from task description. Next line contains N integers smaller than or equal to C, message itself.

출력

First and only line of output should contain N numbers, the sorted sequence.

예제 입력 1

5 2
2 1 2 1 2

예제 출력 1

2 2 2 1 1

예제 입력 2

9 3
1 3 3 3 2 2 2 1 1

예제 출력 2

1 1 1 3 3 3 2 2 2

예제 입력 3

9 77
11 33 11 77 54 11 25 25 33

예제 출력 3

11 11 11 33 33 25 25 77 54
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
#순위사용자언어시간메모리코드 길이
5670🥇
안우진
Python7ms8480KB258B
난이도 투표
Silver III1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
#사용자문제결과언어시간메모리코드 길이제출 시간
5670
맞았습니다
Python7ms8480KB258B2026. 04. 29. 00:51