题解 | #特殊排序#
特殊排序
https://www.nowcoder.com/practice/57f0f528bff149be9580af66f6292430?tpId=40&tqId=21543&tPage=1&rp=1&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking
#include <iostream>
#include<algorithm>
using namespace std;
const int MAX = 1000 + 10;
int arr[MAX];
int main() {
int n;
while(cin >> n){
for(int i = 0;i < n;i++){
cin >> arr[i];
}
sort(arr,arr + n);
cout << arr[n - 1] << endl;
if(n == 1){
cout << -1;
}else{
for(int i = 0;i < n -1;i++){
cout << arr[i] << ' ';
}
}
}
}
// 64 位输出请用 printf("%lld")
