Submission #67948

# Submission time Handle Problem Language Result Execution time Memory
67948 2018-08-15T15:20:46 Z aome Election (BOI18_election) C++17
28 / 100
15 ms 1060 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 248 KB Output is correct
2 Correct 14 ms 428 KB Output is correct
3 Correct 10 ms 560 KB Output is correct
4 Correct 15 ms 628 KB Output is correct
5 Correct 11 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 248 KB Output is correct
2 Correct 14 ms 428 KB Output is correct
3 Correct 10 ms 560 KB Output is correct
4 Correct 15 ms 628 KB Output is correct
5 Correct 11 ms 628 KB Output is correct
6 Incorrect 3 ms 1060 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 248 KB Output is correct
2 Correct 14 ms 428 KB Output is correct
3 Correct 10 ms 560 KB Output is correct
4 Correct 15 ms 628 KB Output is correct
5 Correct 11 ms 628 KB Output is correct
6 Incorrect 3 ms 1060 KB Output isn't correct
7 Halted 0 ms 0 KB -