반응형
1267번: 핸드폰 요금
동호가 저번 달에 이용한 통화의 개수 N이 주어진다. N은 20보다 작거나 같은 자연수이다. 둘째 줄에 통화 시간 N개가 주어진다. 통화 시간은 10,000보다 작거나 같은 자연수이다.
www.acmicpc.net
정답률이 낮아서 혹시나 뭐 빼먹은건 없나 꼼꼼하게 읽으면서 풀게 되네요 ㅋㅋ
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] calltime = new int[N];
for (int i=0; i<N; i++) calltime[i] = sc.nextInt();
// 영식 요금제
int Y = 0;
for (int i : calltime)
Y += (i / 30 + 1) * 10;
// 민식 요금제
int M = 0;
for (int i : calltime)
M += (i / 60 + 1) * 15;
if (Y<M) System.out.print("Y " + Y);
else if (Y>M) System.out.print("M " + M);
else System.out.print("Y M " + M);
}
}

반응형
'Algorithm' 카테고리의 다른 글
백준 15655번 N과 M (6) [ Java ] (0) | 2020.12.23 |
---|---|
백준 15654번 N과 M (5) [ Java ] (0) | 2020.12.23 |
백준 10804번 카드 역배치 [ Java ] (0) | 2020.12.23 |
백준 2445번 별 찍기 - 8 [ Java ] (0) | 2020.12.22 |
백준 2444번 별 찍기 - 7 [ Java ] (0) | 2020.12.21 |