제출 #60548

#제출 시각아이디문제언어결과실행 시간메모리
60548SpaimaCarpatilorElection (BOI18_election)C++17
0 / 100
13 ms376 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

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);
     ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...