Submission #570080

# Submission time Handle Problem Language Result Execution time Memory
570080 2022-05-28T14:09:52 Z Tsiannis Election (BOI18_election) C++17
0 / 100
9 ms 340 KB
#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
1 Incorrect 9 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -