简单到爆,仅需反向排序,然后正向输出
2025-07-23 18:53:26
发布于:广东
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int n , m , a[1000010];
bool cmp(int x , int y){
return x > y;
}
int main(){
cin >> n >> m;
for(int i=1;i<=n;i++){
cin >> a[i];
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=m;i++){
cout << a[i] << " ";
}
return 0;
}
这里空空如也
有帮助,赞一个