Advertisement
theo830

ok

Sep 4th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. int main() {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. ll x;
  8. cin>>x;
  9. if(x == 0){
  10. cout<<"Yes";
  11. return 0;
  12. }
  13. if(x % 2 == 1){
  14. cout<<"No";
  15. return 0;
  16. }
  17. string a;
  18. cin>>a;
  19. int b=0;
  20. int lathi=0;
  21. for(int i=0;i<x;i++){
  22. if(a[i] == '('){
  23. b++;
  24. }
  25. else{
  26. if(b == 0){
  27. lathi++;
  28. b++;
  29. }
  30. b--;
  31. }
  32. }
  33. //cout<<lathi<<endl;
  34. if(lathi <= 1){
  35. cout<<"Yes";
  36. }
  37. else{
  38. cout<<"No";
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement