Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- string s;
- cin >> s;
- int n = s.size();
- bool f = true;
- int cnt = 0;
- for(int i = 0; i < n; i++){
- if(s[i] == '(')
- cnt++;
- else{
- cnt--;
- if(cnt < 0){
- f = false;
- }
- }
- }
- if(cnt > 0)
- f = false;
- if(f){
- cout << "YES" << endl;
- }else{
- cout << "NO" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement