Submission #60719

#TimeUsernameProblemLanguageResultExecution timeMemory
60719SpaimaCarpatilorElection (BOI18_election)C++17
28 / 100
10 ms640 KiB
#include<bits/stdc++.h> using namespace std; int N, M, v[2018], h[2018], s[2018], a[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); for (int i=1; i<=N; i++) a[i] = (sir[i] == 'C' ? +1 : -1), s[i] = s[i - 1] + a[i]; scanf ("%d", &M); while (M --) { int L, R; scanf ("%d %d", &L, &R); int curr = 0, cnt = 0; for (int i=L; i<=R; i++) if (sir[i] == 'C') curr ++, ap[i] = 1; else if (curr == 0) cnt ++, ap[i] = 0; else curr --, ap[i] = 1; curr = 0; int mini = 0; for (int i=R; i>=L; i--) if (ap[i]) curr += a[i], mini = min (mini, curr); printf ("%d\n", cnt - mini); } return 0; }

Compilation message (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:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d", &M);
 ~~~~~~^~~~~~~~~~
election.cpp:22: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...