本场详细题解见:https://blog.csdn.net/xiang_6/article/details/83549528
题意&思路见上述链接
#include<bits/stdc++.h>
using namespace std;
#define out fflush(stdout)
#define fast ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
const int maxn = 256 + 7;
const int INF = 0x3f3f3f3f;
int n;
char s[maxn];
int main() {
scanf("%d", &n);
scanf("%s", s+1);
int ans1 = 0, ans2 = 0;
bool f = 0;
int cur = 0;
for(int i = 1; i <= n; ++i) {
if(s[i] == '(') {
f = 1;
if(cur) ans1 = max(ans1, cur);
cur = 0;
continue;
}
if(s[i] == ')') {
f = 0;
if(cur) ans2++;
cur = 0;
continue;
}
if(s[i] == '_') {
if(!f) {
ans1 = max(ans1, cur);
cur = 0;
}
else {
if(cur) ans2++;
}
cur = 0;
}
else {
cur++;
}
}
if(cur) ans1 = max(ans1, cur);
printf("%d %d\n", ans1, ans2);
return 0;
}