코딩테스트

[백준] 20365 블로그2

주니어주니 2023. 5. 4. 14:39

 

 

 

 

 

 

 

 

 

import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String s = sc.next();
        
        int bCnt = 0, rCnt = 0;
        for(int i=0; i < N; i++) {
            if(s.charAt(i) == 'B')
                bCnt++;
            else if(s.charAt(i) == 'R')
                rCnt++;
        }
        
        int cnt = 0; 
        if(bCnt == 0 || rCnt == 0) {
            cnt = 1;
        } else if(bCnt > rCnt) {
            cnt = rCnt + 1;
        } else if(rCnt > bCnt) {
            cnt = bCnt + 1;
        }
        
        System.out.println(cnt);
    }
}

 

 

이 코드 자꾸 틀렸다고 하는데 도대체 왜 틀린건지 아무리 생각해도 모르겠어요 개짜증난다

누가 알려주세요 제발 아악 ㅠ 

테스트코드는 다 맞게 나오는거같은데 도대체 왜자꾸 틀렸다는건지?!?!!