Advertisement
jbn6972

Untitled

Nov 9th, 2022
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. // Code Written by : John Nixon
  2. // Date: 09:11:2022 Time: 21:23:26
  3. // Copyrights are applicable
  4. #include <bits/stdc++.h>
  5. using namespace std;
  6. #define int long long int
  7. #define mod 1e9 + 7
  8. #define F first
  9. #define S second
  10. #define pb push_back
  11. #define si set<int>
  12. #define vi vector<int>
  13. #define pii pair<int, int>
  14. #define vpi vector<pii>
  15. #define vpp vector<pair<int, pii>>
  16. #define mii map<int, int>
  17. #define mpi map<pii, int>
  18. #define spi set<pii>
  19. #define endl "\n"
  20. #define sz(x) ((int)x.size())
  21. #define all(p) p.begin(), p.end()
  22. #define double long double
  23. #define que_max priority_queue<int>
  24. #define que_min priority_queue<int, vi, greater<int>>
  25. #define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
  26. #define print(a) \
  27. for (auto x : a) \
  28. cout << x << " "; \
  29. cout << endl
  30. #define print1(a) \
  31. for (auto x : a) \
  32. cout << x.F << " " << x.S << endl
  33. #define print2(a, x, y) \
  34. for (int i = x; i < y; i++) \
  35. cout << a[i] << " "; \
  36. cout << endl
  37. inline int power(int a, int b)
  38. {
  39. int x = 1;
  40. while (b)
  41. {
  42. if (b & 1)
  43. x *= a;
  44. a *= a;
  45. b >>= 1;
  46. }
  47. return x;
  48. }
  49.  
  50. template <typename Arg1>
  51. void __f(const char *name, Arg1 &&arg1) { cout << name << " : " << arg1 << endl; }
  52. template <typename Arg1, typename... Args>
  53. void __f(const char *names, Arg1 &&arg1, Args &&...args)
  54. {
  55. const char *comma = strchr(names + 1, ',');
  56. cout.write(names, comma - names) << " : " << arg1 << " | ";
  57. __f(comma + 1, args...);
  58. }
  59. const int N = 200005;
  60.  
  61. void solve()
  62. {
  63. int n;
  64. cin >> n;
  65. int a[2 * n];
  66. for (int i = 0; i < 2 * n; i++)
  67. {
  68. cin >> a[i];
  69. }
  70. sort(a, a + 2 * n);
  71. int i = 0;
  72. int j = 2 * n - 1;
  73.  
  74. mii mp;
  75. while (i < j)
  76. {
  77. if (i % 2 == 0)
  78. {
  79. mp[a[i] - a[j]]++;
  80. }
  81. else
  82. {
  83. mp[(a[i] - a[j]) * -1]++;
  84. }
  85.  
  86. i++;
  87. j--;
  88. }
  89.  
  90. int max_i = 0;
  91. for(auto i:mp){
  92. if(i.S>max_i){
  93. max_i = i.S;
  94. }
  95. }
  96. n = (n+1)/2;
  97. if(max_i <= n){
  98. cout<<"YES"<<endl;
  99. }
  100. else{
  101. cout<<"NO"<<endl;
  102. }
  103. }
  104. int32_t main()
  105. {
  106. ios_base::sync_with_stdio(0);
  107. cin.tie(0);
  108. cout.tie(0);
  109. #ifndef ONLINE_JUDGE
  110. freopen("input.txt", "r", stdin);
  111. freopen("output.txt", "w", stdout);
  112. #endif
  113. clock_t z = clock();
  114. int t = 1;
  115. cin >> t;
  116. while (t--)
  117. solve();
  118. cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
  119. return 0;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement