Solution for CCC '14 J2 - Vote Count in Java 8


Nov. 5, 2019 1.328084 seconds Java 8
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        String b = in.next();
        int count = 0;
        
        for(int i = 0; i < a; i++){
            if(b.charAt(i) == 'A'){
                count++;
            }
        }
        
        
        if(count > a - count){
            System.out.println("A");
        }else if(a - count > count){
            System.out.println("B");
        }else if((a - count) == count){
            System.out.println("Tie");
        }

    }
}

Editorial


No editorial for this problem. :(

Original Problem


You can view the original page for this problem on the DMOJ.