# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
67949 |
2018-08-15T15:21:04 Z |
aome |
Election (BOI18_election) |
C++17 |
|
12 ms |
720 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n, m;
string s;
bool del[N];
int main() {
ios::sync_with_stdio(false);
cin >> n >> s, s = ' ' + s;
if (n >= N) return 0;
cin >> m;
while (m--) {
int l, r; cin >> l >> r;
int cnt = 0, sum = 0;
for (int i = l; i <= r; ++i) {
sum += (s[i] == 'T' ? -1 : 1);
if (sum < 0) sum++, cnt++, del[i] = 1;
}
sum = 0;
for (int i = r; i >= l; --i) {
if (del[i]) continue;
sum += (s[i] == 'T' ? -1 : 1);
if (sum < 0) sum++, cnt++, del[i] = 1;
}
cout << cnt << '\n';
for (int i = l; i <= r; ++i) del[i] = 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
376 KB |
Output is correct |
3 |
Correct |
10 ms |
428 KB |
Output is correct |
4 |
Correct |
12 ms |
444 KB |
Output is correct |
5 |
Correct |
11 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
376 KB |
Output is correct |
3 |
Correct |
10 ms |
428 KB |
Output is correct |
4 |
Correct |
12 ms |
444 KB |
Output is correct |
5 |
Correct |
11 ms |
500 KB |
Output is correct |
6 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
376 KB |
Output is correct |
3 |
Correct |
10 ms |
428 KB |
Output is correct |
4 |
Correct |
12 ms |
444 KB |
Output is correct |
5 |
Correct |
11 ms |
500 KB |
Output is correct |
6 |
Incorrect |
2 ms |
720 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |