#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main ()
{
ll n; cin>>n;
string s; cin>>s;
ll q; cin>>q;
while(q--)
{
ll l,r;
cin>>l>>r; l--;r--;
ll cc=0; ll ct=0;
ll ans1=0;
for (int i=l;i<=r;i++)
{
if (s[i]=='C')
cc++;
else
{
if (ct==cc)
{
ans1++;
}
else
{
ct++;
}
}
}
ct=0; cc=0;
ll ans2=0;
for (int i=r;i>=l;i--)
{
if (s[i]=='C')
cc++;
else
{
if (ct==cc)
{
ans2++;
}
else
{
ct++;
}
}
}
cout<<max(ans1,ans2)<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |