백준: 23235번 The Fastest Sorting Algorithm In The World (Python3)
The Fastest Sorting Algorithm In The World 성공다국어
1 초 | 1024 MB | 482 | 348 | 300 | 73.350% |
문제
It is common to compare sorting algorithms based on their asymptotic speeds. Some slower algorithms like selection sort take O(N2) time to sort N items, while comparison-based sorts like merge sort can go no faster than O(N log(N)) time, under reasonable assumptions. Bucket sort, which is not a comparison-based sort, can sort in O(N) time. This is because bucket sort assumes that the range of possible values is small relative to N. In general, the speed of a sorting algorithm depends on the assumptions it can make about the data it is sorting.
One sorting algorithm that is often overlooked, despite its speed, is The Fastest Sorting Algorithm In The World. It sorts in O(1), or constant, time. Of course, the algorithm assumes that the input is an array that is already in fast-access memory and that the input is already sorted. For this problem, implement The Fastest Sorting Algorithm In The World.
입력
The input file contains multiple test cases, each of which describes an array to sort. Each array description starts with an integer 0 < N ≤ 100. N is followed by the N integers to sort, which will be given in non-decreasing order. All integers to sort are in the range of 0 to 100000. The last test case is followed by a line containing a single zero.
출력
For each test case, print the case number (beginning with 1) followed by the text Sorting... done!
예제 입력 1
5 21 44 48 48 64
6 8 19 22 49 53 62
8 5 9 14 17 24 25 27 61
4 13 21 28 35
5 31 38 44 49 60
0
예제 출력 1
Case 1: Sorting... done!
Case 2: Sorting... done!
Case 3: Sorting... done!
Case 4: Sorting... done!
Case 5: Sorting... done!
답안
1
2
3
4
5
6
7
8
9
|
cnt=0
while(True):
if input()=="0":
break;
else:
cnt=cnt+1
fmt = f"Case {cnt}: Sorting... done!"
print(fmt)
|
cs |
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 21665번 Миша и негатив (Python3) (2) | 2022.08.09 |
---|---|
백준: 22015번 金平糖 (Konpeito) (Python3) (0) | 2022.08.09 |
백준: 23375번 Arm Coordination (Python3) (0) | 2022.08.09 |
백준: 23795번 사장님 도박은 재미로 하셔야 합니다 (Python3) (0) | 2022.08.09 |
백준: 23825번 SASA 모형을 만들어보자 (Python3) (0) | 2022.08.09 |
댓글