문제
https://www.acmicpc.net/problem/25304
25304번: 영수증
준원이는 저번 주에 살면서 처음으로 코스트코를 가 봤다. 정말 멋졌다. 그런데, 몇 개 담지도 않았는데 수상하게 높은 금액이 나오는 것이다! 준원이는 영수증을 보면서 정확하게 계산된 것
www.acmicpc.net
내가 작성한 코드
import java.io.*;
public class 백준25304 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int money = Integer.parseInt(br.readLine());
int num = Integer.parseInt(br.readLine());
int sum = 0;
for(int i = 0; i<num; i++){
String[] input = br.readLine().split(" ");
int price = Integer.parseInt(input[0]);
int quan = Integer.parseInt(input[1]);
sum += price * quan;
}
if(money == sum){
bw.write("Yes");
}
else{
bw.write("No");
}
bw.close();
}
}
'자바 > 백준' 카테고리의 다른 글
[백준 10809] 알파벳 찾기 (0) | 2022.09.06 |
---|---|
[백준 10757] 큰 수 A+B (0) | 2022.09.06 |
[백준 13909] 창문 닫기 (0) | 2022.08.26 |
[백준 5671] 호텔 방 번호 (0) | 2022.08.24 |
[백준 4796] 캠핑 (0) | 2022.08.23 |