백준 #1267번 핸드폰 요금

jhj·2024년 3월 3일

백준 JAVA

목록 보기
438/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int totalY = 0;
		int totalM = 0;
		
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			totalY += (a / 30 + 1) * 10;
			totalM += (a / 60 + 1) * 15;
		}
		
		if(totalY > totalM) {
			System.out.println("M " + totalM);
		}else if(totalY < totalM) {
			System.out.println("Y " + totalY);
		}else {
			System.out.println("Y M " + totalM);
		}
		
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글