Submission #480826

# Submission time Handle Problem Language Result Execution time Memory
480826 2021-10-18T10:00:36 Z Karabasan Election (BOI18_election) C++17
0 / 100
21 ms 332 KB
#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

election.cpp: In function 'void solve()':
election.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -