Created
March 19, 2023 17:12
-
-
Save qjatn0120/5ece5aa36649661711cdb99365a9222b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
cin.tie(nullptr), ios::sync_with_stdio(false); | |
int t; | |
cin >> t; | |
while(t--){ | |
int n; | |
cin >> n; | |
vector <int> c(n); | |
for(int i = 0; i < n; i++) cin >> c[i]; | |
sort(c.begin(), c.end()); | |
long long int sum = 1; | |
bool flag = true; | |
if(c[0] != 1) flag = false; | |
for(int i = 1; i < n; i++){ | |
if(c[i] > sum) flag = false; | |
sum += c[i]; | |
} | |
cout << (flag ? "Yes\n" : "No\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment