Sort
의견: 0
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 believes frequency 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 times \(Y\) does. If the number of appearances is equal, the number whose 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 \le N \le 1\,000\)), length of message, and \(C\) (\(1 \le C \le 1\,000\,000\,000\)), the number from task description.
Next line contains \(N\) integers smaller than or equal to \(C\), the message itself.
The first and only line of output should contain \(N\) numbers, the sorted sequence.
| 서브태스크 | 점수 | 설명 |
|---|---|---|
Test 1 | 10점 | None |
Test 2 | 10점 | None |
Test 3 | 10점 | None |
Test 4 | 10점 | None |
Test 5 | 10점 | None |
Test 6 | 10점 | None |
Test 7 | 10점 | None |
Test 8 | 10점 | None |
Test 9 | 10점 | None |
Test 10 | 10점 | None |
5 2
2 1 2 1 22 2 2 1 19 3
1 3 3 3 2 2 2 1 11 1 1 3 3 3 2 2 29 77
11 33 11 77 54 11 25 25 3311 11 11 33 33 25 25 77 54평가 및 의견
Sort
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Sort