fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5.  
  6. void solve() {
  7. int n;
  8. cin >> n;
  9. vector<int> a(n);
  10. for(int i=0;i<n;i++){
  11. cin >> a[i];
  12. if(a[i]<=0) a[i]=-a[i];}
  13. int k = a[0];
  14. sort(a.begin(),a.end());
  15. for(int i=0;i<n/2+1;i++){
  16. if(a[i]==k){
  17. cout << "YES\n";
  18. return;
  19. }
  20. }
  21. cout << "NO\n";
  22. }
  23.  
  24. int main(){
  25. ios::sync_with_stdio(false);
  26. cin.tie(nullptr);
  27.  
  28. int t;
  29. cin >> t;
  30. while (t--) solve();
  31.  
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5308KB
stdin
7
3
2 3 1
5
1 2 3 4 5
4
4 2 0 -5
4
-5 0 4 3
4
-10 8 3 2
1
1
10
9 1000 -999 -13 456 -223 23 24 10 0
stdout
YES
YES
YES
NO
NO
YES
YES