Accepted
代码
#include<bits/stdc++.h>
int main()
{
std::string s;std::getline(std::cin,s);
int lens,ans=0,left=0;
lens=s.size()-1;
for(int i=0;i<=lens;i++)
{
if(s[i]=='(')left++;
if(s[i]==')')
{
if(left)left--;
else {ans++;left++;}
}
}
if(left)ans+=left/2;
std::cout<<ans;
return 0;
}