답안 #577922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
577922 2022-06-15T13:05:34 Z AlperenT Election (BOI18_election) C++17
28 / 100
6 ms 360 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2e3 + 5;

int n, q, arr[N], arr2[N], l, r, sum;

char c;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	cin >> n;

	for(int i = 1; i <= n; i++){
		cin >> c;

		arr[i] = (c == 'C' ? 1 : -1);
	}

	cin >> q;

	while(q--){
		cin >> l >> r;

		copy(arr + l, arr + r + 1, arr2 + l);

		sum = 0;

		for(int i = l; i <= r; i++){
			if(sum + arr2[i] < 0) arr2[i] = 0;

			sum += arr2[i];
		}

		sum = 0;

		for(int i = r; i >= 1; i--){
			if(sum + arr2[i] < 0) arr2[i] = 0;

			sum += arr2[i];
		}

		cout << count(arr2 + l, arr2 + r + 1, 0) << "\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 6 ms 288 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 5 ms 360 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 6 ms 288 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 5 ms 360 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
6 Incorrect 1 ms 336 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 6 ms 288 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
4 Correct 5 ms 360 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
6 Incorrect 1 ms 336 KB Output isn't correct
7 Halted 0 ms 0 KB -