답안 #159619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
159619 2019-10-23T14:33:52 Z iefnah06 Election (BOI18_election) C++11
28 / 100
3000 ms 1460 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 5.1e5;
int N, Q;
string S;

string go(string s) {
	string t;
	int cur = 0;
	for (char c : s) {
		if (c == 'C') {
			cur++;
			t += c;
		} else if (cur > 0) {
			cur--;
			t += c;
		}
	}
	return t;
}

int solve(string s) {
	string t = go(s);
	reverse(t.begin(), t.end());
	t = go(t);
	return int(s.size() - t.size());
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> S >> Q;
	while (Q--) {
		int l, r; cin >> l >> r; l--;
		cout << solve(S.substr(l, r-l)) << '\n';
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 376 KB Output is correct
2 Correct 27 ms 376 KB Output is correct
3 Correct 33 ms 344 KB Output is correct
4 Correct 21 ms 376 KB Output is correct
5 Correct 18 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 376 KB Output is correct
2 Correct 27 ms 376 KB Output is correct
3 Correct 33 ms 344 KB Output is correct
4 Correct 21 ms 376 KB Output is correct
5 Correct 18 ms 376 KB Output is correct
6 Execution timed out 3049 ms 1460 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 376 KB Output is correct
2 Correct 27 ms 376 KB Output is correct
3 Correct 33 ms 344 KB Output is correct
4 Correct 21 ms 376 KB Output is correct
5 Correct 18 ms 376 KB Output is correct
6 Execution timed out 3049 ms 1460 KB Time limit exceeded
7 Halted 0 ms 0 KB -