Submission #793107

#TimeUsernameProblemLanguageResultExecution timeMemory
793107pasin30055Election (BOI18_election)C++14
28 / 100
6 ms724 KiB
#include <cstdio> #include <cstdlib> #include <iostream> #define MAXN 2005 using namespace std; int n, q, l, r; int a[MAXN], b[MAXN], c[MAXN], d[MAXN]; char s[MAXN]; int main() { scanf("%d\n%s\n%d", &n, s, &q); for (; q > 0; q --) { scanf("%d %d", &l, &r); a[l - 1] = 0; b[r + 1] = 0; c[l - 1] = 0; d[r + 1] = 0; int ans = 0; for (int i = l ; i <= r ; i ++) { a[i] = a[i - 1]; if (s[i - 1] == 'C') a[i]--; else a[i]++; c[i] = max(c[i - 1], a[i]); } for (int i = r ; i >= l; i --) { b[i] = b[i + 1]; if (s[i - 1] == 'C') b[i]--; else b[i]++; d[i] = max(d[i + 1], b[i]); ans = max(ans, d[i + 1] + c[i]); } printf("%d\n", ans); } 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]
   14 |  scanf("%d\n%s\n%d", &n, s, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
election.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d %d", &l, &r);
      |   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...