Submission #565600

# Submission time Handle Problem Language Result Execution time Memory
565600 2022-05-21T07:17:32 Z Dodo Election (BOI18_election) C++14
28 / 100
3000 ms 1172 KB
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pb push_back
using namespace std;

int main()
{
  ll n,q;
  string s;
  cin>>n>>s>>q;
  while(q--)
  {
    ll x,y;
    cin>>x>>y;
    x--;
    y--;
    ll arr[n]={};
    ll t=0,c=0;
    for(int i=x;i<=y;i++)
    {
      if(s[i]=='C')c++;
      else t++;
      if(t>c)
      {
        arr[i]++;
        t--;
      }
    }
    t=0,c=0;
    for(int i=y;i>=x;i--)
    {
      if(s[i]=='C')c++;
      else if(arr[i]==0)t++;
      if(t>c)
      {
        arr[i]++;
        t--;
      }
    }
    ll ans=0;
    for(int i=0;i<n;i++)
      if(arr[i]>0)ans++;
    cout<<ans<<endl;
  }
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 212 KB Output is correct
2 Correct 14 ms 212 KB Output is correct
3 Correct 14 ms 212 KB Output is correct
4 Correct 18 ms 320 KB Output is correct
5 Correct 15 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 212 KB Output is correct
2 Correct 14 ms 212 KB Output is correct
3 Correct 14 ms 212 KB Output is correct
4 Correct 18 ms 320 KB Output is correct
5 Correct 15 ms 320 KB Output is correct
6 Execution timed out 3063 ms 1172 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 212 KB Output is correct
2 Correct 14 ms 212 KB Output is correct
3 Correct 14 ms 212 KB Output is correct
4 Correct 18 ms 320 KB Output is correct
5 Correct 15 ms 320 KB Output is correct
6 Execution timed out 3063 ms 1172 KB Time limit exceeded
7 Halted 0 ms 0 KB -