코딩테스트

JAVA - 백준 30031, 25640

whyHbr 2024. 3. 19. 23:00
728x90
반응형
import java.util.Scanner;

public class BOJ30031 {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int N = sc.nextInt();
        int[] width = new int [N];
        int[]height =new int [N];
        int total =0;
        for (int i=0; i<width.length; i++){
            width[i] = sc.nextInt();
            height[i] = sc.nextInt();
        }
        for(int i=0; i< width.length; i++){
            if(width[i] == 136){
                total +=1000;
            }else if( width[i] == 142){
                total +=5000;
            }else if( width[i] == 148){
                total += 10000;
            }else if(width[i] ==154){
                total +=50000;
            }
        }
        System.out.println(total);
        sc.close();

    }
}
import java.util.Scanner;

public class BOJ25640 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String jinho = sc.nextLine();
        int f = sc.nextInt();
        sc.nextLine();
        String[] fType = new String[f];

        int total = 0;
        for(int i=0; i< f; i++){
            fType[i] = sc.nextLine();

            if(jinho.equals(fType[i])){
                 total++ ;
            }
        }
        sc.close();
        System.out.println(total);
    }
}
728x90