CF_726_C

Run Settings
LanguageC++
Language Version
Run Command
// Problem: C. Challenging Cliffs // Contest: Codeforces - Codeforces Round #726 (Div. 2) // URL: https://codeforces.com/contest/1537/problem/C // Memory Limit: 256 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) #include "bits/stdc++.h" #define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; using ll = long long; int main(){ FIO ll t ; cin >> t ; while(t--){ ll n ; cin>> n ; vector<ll> v(n , 0 ) ; for(auto &c : v)cin>> c; sort(v.begin() , v.end()) ; ll Min = INT_MAX , idx = -1 ; for(int i = 1 ; i < n ;i++){ if(Min > (v[i]-v[i-1])){ Min = (v[i]-v[i-1]) ; idx = i ; } } cout<< v[idx-1] <<" " ; for(int i = idx+1 ; i < n ;i++ ){ cout << v[i] << " " ; } for(int i = idx-2 ; i >= 0 ; i--){ cout << v[i] <<" " ; } cout<<v[idx] << "\n" ; } return 0 ; }
Editor Settings
Theme
Key bindings
Full width
Lines