#include "bits/stdc++.h"
using namespace std;
signed main () {
int n;
cin >> n;
string str;
cin >> str;
int q;
cin >> q;
while(q --) {
int l, r;
cin >> l >> r;
l --, r --;
int bal = 0, cnt1 = 0, cnt2 = 0;
for(int i = l; i <= r; i ++) {
if(str[i] == 'C') bal ++;
else if(bal == 0) {
cnt1 ++;
}else bal --;
}
bal = 0;
for(int i = r; i >= l; i --) {
if(str[i] == 'C') bal ++;
else if(bal == 0) {
cnt2 ++;
}else bal --;
}
cout << max(cnt1, cnt2) << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |