2026-02-04 21:50:24 +09:00

28 lines
610 B
Swift

func solve() {
guard let _ = readLine(),
let input = readLine(),
let callingTime = input.split(separator: " ").compactMap({Int($0)}) as? [Int]
else { return }
let YS = { ( ( $0 / 30 ) + 1 ) * 10 }
let MS = { ( ( $0 / 60 ) + 1 ) * 15 }
var (YS_price, MS_price) = (0, 0)
for time in callingTime {
YS_price += YS(time)
MS_price += MS(time)
}
if YS_price < MS_price {
print("Y", YS_price)
}
else if YS_price > MS_price {
print("M", MS_price)
}
else {
print("Y M", YS_price)
}
}
solve()