-
Notifications
You must be signed in to change notification settings - Fork 0
/
1856_B.cpp
41 lines (36 loc) · 845 Bytes
/
1856_B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
long long int n;
cin>>n;
long long int arr[n];
for (int i = 0; i < n; i++)
{
cin>>arr[i];
}
// sort(arr,arr+n);
// if(arr.size()==1){
// cout<<0;
// }
long long int count_ones = 0, sum=0;
for (int i = 0; i < n; i++)
{
sum+=arr[i];
if(arr[i]==1) count_ones++;
}
// for (int i = 0; i < n; i++)
// {
// if(arr[i]!=1){
// arr[i]-=1;
// }
// }
if(sum>=count_ones+n && n>1){
cout<<"YES"<<endl;
}
else cout<<"NO"<<endl;
}
return 0;
}