感谢大佬!!
#include<bits/stdc++.h>
using namespace std;
stack <char> s;
char a[300];
int len;
int main(){
cin>>a;
len=strlen(a);
for(int i=0;i<len;i++){
if(a[i]=='(') s.push(a[i]);
if(a[i]==')'){
if(s.top()=='(') s.pop();
}
}
if(s.empty()) printf("YES");
else printf("NO");
return 0;
}