-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1374C.cpp
More file actions
32 lines (29 loc) · 670 Bytes
/
Copy path1374C.cpp
File metadata and controls
32 lines (29 loc) · 670 Bytes
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
#include <bits/stdc++.h>
#define FOR(i, start, end) for(int i = start; i < end; i++)
using namespace std;
typedef long long LL;
int main() {
int t;
cin >> t;
while (t--) {
int n, comp = 0;
cin >> n;
string s;
cin >> s;
int open = 0, close = 0;
FOR(i, 0, s.length()) {
if (s[i] == '(') {
open++;
}
else if (s[i] == ')') {
if (open > 0) {
open--;
comp++;
} else {
close++;
}
}
}
cout << (n>>1) - comp << '\n';
}
}