답안 #529958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529958 2022-02-24T06:48:35 Z scottchou Growing Vegetable is Fun 3 (JOI19_ho_t3) C++17
0 / 100
1 ms 204 KB
#include<iostream>
using namespace std;
int const N = 405;
char a[N];
int main(){
    int n;
    cin >> n;
    int R = 0, G = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 'R'){
            R++;
        }else {
            G++;
        }
    }
    if(R != n / 2 && G != n / 2){
        cout << -1 << '\n';
    }
    if(n & 1){
        int cnt = 0;
        for(int i = 0; i < n; i += 2){
            if(R > G){
                if(a[i] != 'R'){
                    cnt++;
                }
            }else{
                if(a[i] != 'G'){
                    cnt++;
                }
            }
        }
        cout << cnt << '\n';
    }else{
        int cnt1 = 0, cnt2 = 0;
        for(int i = 0; i < n; i += 2){
            if(a[i] == 'R')
                cnt1++;
            else{
                cnt2++;
            }
        }
        cout << min(cnt1, cnt2) << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -