-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChef_in_Heaven_.cpp
More file actions
54 lines (54 loc) · 1.03 KB
/
Chef_in_Heaven_.cpp
File metadata and controls
54 lines (54 loc) · 1.03 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
int c=0,d=0;
for(int i=0;i<n;i++)
{
if(s[i]=='0')
{
c++;
}
else{
d++;
}
}
if(d>=c)
{
cout<<"YES"<<endl;
}
else{
int al=0,ap=0,gf=0;
for(int i=0;i<n;i++)
{
if(s[i]=='0')
{
al++;
}
else if(s[i]=='1'){
ap++;
}
if(al==ap)
{
gf+=1;
break;
}
}
if(gf==1)
{
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
}
}