Skip to content

Commit e8f8cc0

Browse files
committed
[BOJ] #25329. 학생별 통화 요금 계산 / 실버4 / 23분 / 성공
1 parent 1ab11f1 commit e8f8cc0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
import math
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
7+
# 학생 통화 시간 계산 및 저장
8+
call_log = {}
9+
for _ in range(n):
10+
time, name = map(str, input().split())
11+
hour, minute = map(int, time.split(":"))
12+
13+
if name in call_log:
14+
call_log[name] += minute + hour * 60
15+
else:
16+
call_log[name] = minute + hour * 60
17+
18+
# 통화 요금 계산
19+
charge = {}
20+
for k, v in call_log.items():
21+
if v <= 100:
22+
charge[k] = 10
23+
else:
24+
charge[k] = 10 + math.ceil((v - 100) / 50) * 3
25+
26+
for name, value in sorted(charge.items(), key=lambda x: (-x[1], x[0])):
27+
print(name, value)

0 commit comments

Comments
 (0)