A:水题
题意:
一个排列,它的值为:
(x1 - x2) + (x2 - x3) + … + (xn - 1 - xn)。
输出排列使得他的值最大,且其余元素按字典序最小排列。
题解:
水题果然是水题,Excuse me?最大数在头,最小数在尾,先降序sort一下,其余sort再一下。
#include<iostream>
#include<cstdio>
#include<cmath>
#include <algorithm>
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int main(){
int a[105<