链接:https://codeforces.com/contest/1339/problem/B
题意:给定一个数组,重排后,按绝对值递增;
排序后,从后往前一大一小输出即可;
code:
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e5+10; ll a[maxn],ans[maxn]; void solve() { int n; scanf("%d",&n); for(int i=1; i<=n; i++) scanf("%lld",&a[i]); sort(a+1,a+1+n); int l=1, r=n; for(int i=n; i>=1; i--) { if(i%2) ans[i]=a[r--]; else ans[i]=a[l++]; } for(int i=1; i<=n; i++) printf("%lld ",ans[i]); printf(" "); } int main() { int t; cin>>t; while(t--) solve(); //system("pause"); return 0; }