제출 #1018716

#제출 시각아이디문제언어결과실행 시간메모리
1018716phoenixElection (BOI18_election)C++17
28 / 100
3089 ms1336 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; s = '#' + s; int q; cin >> q; bool us[n + 1] = {}; while (q--) { int l, r; cin >> l >> r; int suf = 0, cur = 0; for (int i = l; i <= r; i++) { suf += (s[i] == 'C'); } int k = 0, cnt = 0; for (int i = l; i <= r; i++) { if (s[i] == 'C') { cur++; if (k) k--; else suf--; cnt++; } else { if (cur && suf) { cur--; suf--; k++; cnt++; } } } cout << r - l + 1 - cnt << '\n'; } }

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

election.cpp: In function 'int main()':
election.cpp:19:10: warning: unused variable 'us' [-Wunused-variable]
   19 |     bool us[n + 1] = {};
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...