forked from buglinjo/codeforces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1374C.cpp
40 lines (40 loc) · 815 Bytes
/
1374C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
int min(int a, int b) {
if (a < b)
return a;
else
return b;
}
bool compare(int a, int b) {
return a > b;
}
int32_t main() {
fio;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s;
cin >> s;
int open = 0, count = 0;
for (int i = 0; i < n; i++) {
if (s[i] == ')') {
open--;
}
else {
if (open < 0)
count = max(count, abs(open));
open++;
//break;
}
}
cout << count << endl;
}
return 0;
}