Submission #60538

#TimeUsernameProblemLanguageResultExecution timeMemory
60538SpaimaCarpatilorElection (BOI18_election)C++17
0 / 100
13 ms376 KiB
#include<bits/stdc++.h>

using namespace std;

int N, M;
char sir[2018];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d\n", &N);
scanf ("%s", sir + 1);
scanf ("%d", &M);
while (M --)
{
    int L, R;
    scanf ("%d %d", &L, &R);
    int curr = 0, cnt1 = 0, cnt2 = 0;
    for (int i=L; i<=R; i++)
        if (sir[i] == 'C') curr ++;
        else
        if (curr == 0) cnt1 ++;
        else curr --;
    curr = 0;
    for (int i=R; i>=L; i--)
        if (sir[i] == 'C') curr ++;
        else
        if (curr == 0) cnt2 ++;
        else curr --;
    printf ("%d\n", max (cnt1, cnt2));
}

return 0;
}

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d\n", &N);
 ~~~~~~^~~~~~~~~~~~
election.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%s", sir + 1);
 ~~~~~~^~~~~~~~~~~~~~~
election.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d", &M);
 ~~~~~~^~~~~~~~~~
election.cpp:19:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &L, &R);
     ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...