这是什么排序(不是)
2024-01-06 23:28:54
发布于:广东
5阅读
0回复
0点赞
脑子一抽想出来的,也是顺利的TLE了好吧
#include <iostream>
#include <cstdio>
using namespace std;
int a[10005], b[10005], c[10005], ct;
int mn = 0x7fffffff;
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
b[i] = a[i];
mn = min(mn, a[i]);
}while(n - ct){
int mnn = 0x7fffffff;
for(int i = 1; i <= n; i++){
if(b[i] != 0){
b[i] -= mn;
if(b[i] == 0) c[++ct] = a[i];
else mnn = min(mnn, b[i]);
}
}mn = mnn;
}for(int i = 1; i <= ct; i++){
cout << c[i] << ' ';
}
return 0;
}
这里空空如也
有帮助,赞一个