#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100001];
ll b[100001];
int main()
{
int n, i;
cin>>n;
for(i=0; i<n; i++)
cin>>a[i];
sort(a, a+n);
if(a[n-1] < a[n-2]+a[n-3])
{
cout<<"YES\n";
swap(a[n-1], a[n-2]);
for(i=0;i<n;i++)
cout<<a[i]<<" ";
}
else cout<<"NO\n";
//system("pause");
}
Codeforces Round #572 (Div. 2) B Number Circle
原文:https://www.cnblogs.com/lightWh1te/p/13731821.html