Skip to content

Instantly share code, notes, and snippets.

@qjatn0120
Created March 19, 2023 17:12
Show Gist options
  • Save qjatn0120/5ece5aa36649661711cdb99365a9222b to your computer and use it in GitHub Desktop.
Save qjatn0120/5ece5aa36649661711cdb99365a9222b to your computer and use it in GitHub Desktop.
#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