제출 #937867

#제출 시각아이디문제언어결과실행 시간메모리
937867sleepntsheepElection (BOI18_election)C11
0 / 100
2 ms2392 KiB
#include<stdio.h> int lo(int a, int b) { return a<b?a:b; } #define N 500000 int n, q; char s[N+1]; int go[N],bk[N]; int f(char c) { return c == 'C' ? 1 : -1; } int main() { scanf("%d%s%d", &n, s, &q); go[0] = f(s[0]); bk[n-1] = f(s[n-1]); for (int i = 1; i < n; ++i) go[i] = go[i-1] + f(s[i]); for (int i = n - 2; i >= 0; --i) bk[i] = bk[i+1] + f(s[i]); for (int x, y, i = 0; i < q; ++i) { scanf("%d%d", &x, &y); --x, --y; int o1 = (x ? go[x-1] : 0), o2 = (y + 1 < n ? bk[y+1] : 0); int z = lo(go[x] - o1, bk[x] - o2); for (int i = x + 1; i <= y; ++i) z = lo(z, lo(go[i] - o1, bk[i] - o2)); printf("%d\n", -z); } }

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

election.c: In function 'main':
election.c:20:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d%s%d", &n, s, &q);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
election.c:27:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%d%d", &x, &y);
      |         ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...