Submission #67947

# Submission time Handle Problem Language Result Execution time Memory
67947 2018-08-15T15:20:14 Z aome Election (BOI18_election) C++17
0 / 100
14 ms 248 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;
		}
		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 Incorrect 14 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -