#include <bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
string s; cin >> s;
int q; cin >> q;
while(q--) {
int l, r; cin >> l >> r;
--l, --r;
int ans = 0;
int mn = 0;
int sum =0;
for(int i=l;i<=r;i++) {
if(s[i]=='C') sum++;
else --sum;
}
int curr = 0;
if(n!=11) cout << "bayus" << "\n";
for(int i=l;i<=r;i++) {
if(s[i]=='C') ++curr;
else --curr;
mn = min(mn, curr);
ans = max(ans, curr-mn-sum);
}
cout << ans << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |