답안 #60548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60548 2018-07-24T10:21:51 Z SpaimaCarpatilor Election (BOI18_election) C++17
0 / 100
13 ms 376 KB
#include<bits/stdc++.h>

using namespace std;

int N, M, v[2018], h[2018];
bool ap[2018];
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, n = 0, m = 0;
    for (int i=L; i<=R; i++)
        if (sir[i] == 'C') curr ++;
        else
        if (curr == 0) v[++n] = i;
        else curr --;
    curr = 0;
    for (int i=R; i>=L; i--)
        if (sir[i] == 'C') curr ++;
        else
        if (curr == 0) h[++m] = i;
        else curr --;
    int p = 1, u = min (n, m), ras = 0;
    while (p <= u)
    {
        int mij = (p + u) >> 1;
        if (v[n - mij + 1] >= h[m]) ras = mij, p = mij + 1;
        else u = mij - 1;
    }
    printf ("%d\n", n + m - ras);
}

return 0;
}

Compilation message

election.cpp: In function 'int main()':
election.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d\n", &N);
 ~~~~~~^~~~~~~~~~~~
election.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%s", sir + 1);
 ~~~~~~^~~~~~~~~~~~~~~
election.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d", &M);
 ~~~~~~^~~~~~~~~~
election.cpp:20:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &L, &R);
     ~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -