728x90
6830번: It’s Cold Here!
Canada is cold in winter, but some parts are colder than others. Your task is very simple, you need to find the coldest city in Canada. So, when given a list of cities and their temperatures, you are to determine which city in the list has the lowest tempe
www.acmicpc.net
문제 풀이
이 문제는 주어지는 입력값 중 가장 낮은 온도의 도시를 출력하는 문제이다. 입력값이 얼마나 들어올 지 모르므로 try - except 문을 사용해 EOF가 입력될 때 까지 입력값을 받도록 해주었다.
저장한 온도보다 낮은 온도가 들어올 때마다, 온도와 도시를 바꿔준다.
정답 코드
import sys
input = sys.stdin.readline
city, temp = "", 201
try :
while True :
c, t = input().split()
if int(t) < temp :
city = c
temp = int(t)
except :
print(city)
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 6889 - Smile with Similes [python] (1) | 2023.03.19 |
---|---|
[BOJ/백준] 6845 - Federal Voting Age [python] (0) | 2023.03.19 |
[BOJ/백준] 6812 - Good times [python] (0) | 2023.03.19 |
[BOJ/백준] 6794 - What is n, Daddy? [python] (0) | 2023.03.19 |
[BOJ/백준] 6784 - Multiple Choice [python] (0) | 2023.03.19 |