# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
480826 | Karabasan | Election (BOI18_election) | C++17 | 21 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")
int n,t,m;
int pre[500005];
void solve()
{
string AAA;
string s="G";
cin>>n;
cin>>AAA;
s+=AAA;
int q;
scanf("%d",&q);
while(q--)
{
int a,b;
cin>>a>>b;
int c=0;
int t=0;
int mx=0;
for(int i=a;i<=n;i++)
{
if(s[i]=='T')
c++;
else c--;
mx=max(mx,c);
}
for(int i=b;i>=a;i--)
{
if(s[i]=='T')
t++;
else t--;
mx=max(mx,t);
}
cout<<mx<<endl;
}
}
int main()
{
// scanf("%d",&t);
t=1;
while(t--)
{
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |