Submission #770165

#TimeUsernameProblemLanguageResultExecution timeMemory
770165allllekssssaElection (BOI18_election)C++14
0 / 100
5 ms340 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; for (int i = l; i <= r; i++) { if (s[i - 1] == 'T') ++cur; else cur--; d[i] = max(0, cur); } cur = 0; for (int i = r; i>=l; i--) { d[i]+=max(0, cur); if (s[i - 1] == 'T') ++cur; else 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...