Submission #343384

#TimeUsernameProblemLanguageResultExecution timeMemory
343384ijxjdjdElection (BOI18_election)C++14
0 / 100
372 ms748 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> s(N); for (int i = 0; i < N; i++) { char c; cin >> c; if (c == 'C') { s[i] = 1; } else { s[i] = -1; } } int Q; cin >> Q; while (Q-->0) { int l, r; cin >> l >> r; l--, r--; unordered_set<int> touched; int cur = 0; for (int i = l; i <= r; i++) { cur += s[i]; if (cur < 0) { cur = 0; touched.insert(i); } } for (int i = r; i >= l; i--) { if (!touched.count(i)) { cur += s[i]; if (cur < 0) { cur = 0; touched.insert(i); } } } for (auto i : touched) { cerr << i << " "; } cout << touched.size() << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...