fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #pragma region Macros
  5. #define Faster ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  6. #define ll long long
  7. #define ld long double
  8. #define pii pair<int, int>
  9. #define pll pair<long long, long long>
  10. #define all(x) x.begin(), x.end()
  11. #define rall(x) x.rbegin(), x.rend()
  12. #define pb push_back
  13. #define ff first
  14. #define ss second
  15. #define endl '\n'
  16. #define yes cout << "YES" << endl
  17. #define no cout << "NO" << endl
  18. #define m1 cout << -1 << endl
  19. #pragma endregion
  20.  
  21. #pragma region Math
  22. const ll MOD = 1e9 + 7;
  23. ll gcd(ll a, ll b) { return __gcd(a, b); }
  24. ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
  25. #pragma endregion
  26.  
  27. void solve() {
  28. int n; cin>>n;
  29. vector<int>v(n);
  30. for(auto &it:v) cin>>it;
  31. int cnt=0;
  32. for(int i=0;i<n;i++){
  33. if(v[i]>=3) {
  34. yes;
  35. return;
  36. }
  37. if(v[i]>=2) cnt++;
  38. }
  39. if(cnt>=2) yes;
  40. else no;
  41. }
  42.  
  43. int main() {
  44. Faster;
  45. int t = 1;
  46. cin >> t;
  47. while (t--) solve();
  48. return 0;
  49. }
Success #stdin #stdout 0s 5316KB
stdin
7
1
1
1
3
1
4
2
2 1
2
3 2
3
1 1 2
4
1 1 2 2
stdout
NO
YES
YES
NO
YES
NO
YES