Submission #770175

#TimeUsernameProblemLanguageResultExecution timeMemory
770175allllekssssaElection (BOI18_election)C++14
28 / 100
5 ms980 KiB
#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; const int maxN = 3000; string s; int n, q; int d[maxN]; int main() { cin >> n; cin >> s; cin >> q; while(q--) { int l, r; scanf("%d%d", &l, &r); int cur = 0; int mm = 0; for (int i = l; i <= r; i++) { if (s[i - 1] == 'T') ++cur; else cur--; mm = max(mm, cur); d[i] = mm; } cur = 0; mm = 0; for (int i = r; i>=l; i--) { d[i]+=mm; if (s[i - 1] == 'T') ++cur; else cur--; mm = max(mm, cur); } int mx = 0; for (int i = l; i<=r; i++) { mx = max(mx, d[i]); } printf("%d\n", mx); } }

Compilation message (stderr)

election.cpp: In function 'int main()':
election.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d%d", &l, &r);
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...