思路
明显,此题的答案只与 的绝对值有关。对于任意 ,当且仅当 时, 的正负性才能影响 在 中的排名。设满足 的 的数量为 ,当 时 才可以成为中位数。
代码
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N=1e5+5;
int a[N];
bool help(){
int n;
cin>>n;
int cnt=0;
for(int i=1;i<=n;i++){
cin>>a[i];
if(abs(a[i])>abs(a[1])){
cnt++;
}
}
if(cnt>=(n-1)/2){
return true;
}
return false;
}
signed main(){
int t;
cin>>t;
while(t--){
cout<<(help()?"YES":"NO")<<endl;
}
return 0;
}