Submission #60538

# Submission time Handle Problem Language Result Execution time Memory
60538 2018-07-24T10:09:48 Z SpaimaCarpatilor Election (BOI18_election) C++17
0 / 100
13 ms 376 KB
#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

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 time Memory Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -