문제
You are one of the developers of software for a real estate agency. One of the functions you are to implement is calculating different kinds of statistics for flats the agency is selling. Each flat consists of different types of rooms: bedroom, bathroom, kitchen, balcony and others.
The cost of the flat is equal to the product of reduced total area and the cost of one square metre. Reduced total area is the total area of all rooms except for balconies plus one half of balconies total area.
You will be given some information about the area of each room in the flat and the cost of one square metre. You are to calculate the following values for the flat:
- the total area of all rooms;
- the total area of all bedrooms;
- the cost of the flat.
입력
The first line of the input file contains two integer numbers n (1 ≤ n ≤ 10) and c (1 ≤ c ≤ 100 000) — number of rooms in the flat and the cost of one square metre, respectively.
Each of the following n lines contains an integer number ai (1 ≤ ai ≤ 100) and a word ti — the area of i-th room and its type, respectively. Word ti is one of the following: “bedroom”, “bathroom”, “kitchen”, “balcony”, “other”.
출력
The first line of the output file should contain one integer number — the total area of all rooms of the flat. The second line of the output file should contain one integer number — the total area of bedrooms of the flat. The third line of the output file should contain one real number — the cost of the flat with precision not worse than 10−6.
풀이
문제에서 주어진대로 모든 방의 면적, 침실의 면적 그리고 아파트 비용을 계산하는 문제다.
아파트 비용의 경우 발코니를 제외한 전체 면적( total ) 에서 발코니 면적의 절반을 뺀( areaOfBalcony / 2 ) 영역에 대해 단위면적당 비용(C)를 곱해 출력해주면 된다.
따라서, 발코니의 면적을 따로 세어주자.
소스코드
출처
'PS > Baekjoon Online Judge' 카테고리의 다른 글
[백준 03578] Holes [Java] (1) | 2023.12.01 |
---|---|
[백준 03533] Explicit Formula [Java] (0) | 2023.11.29 |
[백준 03507] Automated Telephone Exchange [Java] (1) | 2023.11.27 |
[백준 03276] ICONS [Java] (1) | 2023.11.24 |
[백준 03059] 등장하지 않는 문자의 합 [Java] (1) | 2023.11.23 |