이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |