답안 #145386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145386 2019-08-19T18:57:55 Z MKopchev Election (BOI18_election) C++14
28 / 100
3000 ms 1360 KB
#include <bits/stdc++.h>
using namespace std;
const int nmax=5e5+42;
int n,q;
char in[nmax],inp[nmax];
bool out[nmax];
int main()
{
    scanf("%i",&n);
    scanf("%s",&in);

    for(int i=1;i<=n;i++)
        inp[i]=in[i-1];

    scanf("%i",&q);

    int l,r;
    for(int i=1;i<=q;i++)
    {
        scanf("%i%i",&l,&r);
        for(int j=l;j<=r;j++)out[j]=0;
        int c=0,removed=0;
        for(int j=l;j<=r;j++)
        {
            if(inp[j]=='C')c++;
            else
            {
                if(c)c--;
                else out[j]=1,removed++;
            }
        }
        c=0;
        for(int j=r;j>=l;j--)
        {
            if(inp[j]=='C')c++;
            else if(out[j]==0)
            {
                if(c)c--;
                else out[j]=1,removed++;
            }
        }
        printf("%i\n",removed);
    }
}

Compilation message

election.cpp: In function 'int main()':
election.cpp:10:19: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[500042]' [-Wformat=]
     scanf("%s",&in);
                ~~~^
election.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&n);
     ~~~~~^~~~~~~~~
election.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",&in);
     ~~~~~^~~~~~~~~~
election.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i",&q);
     ~~~~~^~~~~~~~~
election.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&l,&r);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 7 ms 380 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 7 ms 380 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Execution timed out 3032 ms 1360 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 7 ms 380 KB Output is correct
4 Correct 9 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Execution timed out 3032 ms 1360 KB Time limit exceeded
7 Halted 0 ms 0 KB -