Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- ll x;
- cin>>x;
- if(x == 0){
- cout<<"Yes";
- return 0;
- }
- if(x % 2 == 1){
- cout<<"No";
- return 0;
- }
- string a;
- cin>>a;
- int b=0;
- int lathi=0;
- for(int i=0;i<x;i++){
- if(a[i] == '('){
- b++;
- }
- else{
- if(b == 0){
- lathi++;
- b++;
- }
- b--;
- }
- }
- //cout<<lathi<<endl;
- if(lathi <= 1){
- cout<<"Yes";
- }
- else{
- cout<<"No";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement