-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem_1465A.cpp
43 lines (40 loc) · 876 Bytes
/
Problem_1465A.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
42
43
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d", &n);
string s;
cin>>s;
if(s.length() == 1 && s == ")"){
cout<<"Yes"<<"\n";
}
else if (s.length() == 2 && s == "))") {
cout<<"Yes"<<"\n";
}
else{
int j = s.length()-1;
int count = 0;
for (int i = 0; i < s.length(); i++)
{
if(s[j--] == ')'){
count++;
}
else{
break;
}
}
if(count > (s.length() - count)){
cout<<"Yes"<<"\n";
}
else{
cout<<"NO"<<"\n";
}
}
}
return 0;
}