Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int t;
- scanf("%d", &t);
- while(t--)
- {
- int n;
- scanf("%d", &n);
- char s[n];
- scanf("%s", s);
- int i, c = 0, ans = 0;
- for(i = 0; i < n; i++)
- {
- if(s[i] == '(') c++;
- else c--;
- if(c < 0)
- {
- c = 0;
- ans++;
- }
- }
- printf("%d\n", ans);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment