有很多種排序方法,像是 Merge Sort, Radix sort, Bubble sort, Selection Sort, Quick Sort, Bogo Sort。
今天一個漁人給你一個長度為 n 的相異非負整數陣列 a1∼an,他說:「今天你沒排序好這個陣列就別想給我吃魚!」
為了吃到魚肉,你必須由小到大排序好這個陣列並輸出,但是你只有 5 MB 的記憶體。
「怎麼辦…」你不知所措,這時木木力口口力現身了,「不要怕,讓我來教你吧!」
第一行有一個正整數 n,代表陣列大小。
第二行有 n 個非負整數 a1∼an。
輸出 n 個數字,代表陣列排序後的結果。
5 500 300 200 400 100
100 200 300 400 500
#include <iostream> 或 #include <bits/stdc++.h> 後很可能就會超過限制了,建議 #include <cstdio> 或其他不會超過限制的函式庫。
#include <iostream>
#include <bits/stdc++.h>
#include <cstdio>
:25%:n≤105
:無特別限制75%:無特別限制