python-algorithm

백준 3512 Flat

무적김두칠 2022. 12. 31. 12:10

https://www.acmicpc.net/problem/3512

 

3512번: Flat

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, k

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if __name__ == '__main__':
    n, c = map(int,input().split())
    area_rooms = 0
    area_bedrooms = 0
    area_balcony = 0
    for _ in range(n):
        ai, ti = input().split()
        area_rooms += int(ai)
        if ti == 'bedroom':
            area_bedrooms += int(ai)
        if ti == 'balcony':
            area_balcony += int(ai)
    cost_flat = (area_rooms-(area_balcony/2))*c
    print(area_rooms)
    print(area_bedrooms)
    print(cost_flat)
 
cs
반응형