CCC '08 S1 - It's Cold Here!

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type

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 temperature and is thus the coldest.


The input is a sequence of city names and temperature values. Temperatures are integer, possibly preceded with a "minus" sign. There is a single space between the city name and the temperature. No city name contains any whitespace and is always less than 256 characters in length. There is at least one city in the list, no more than 10\,000 cities, and the last city is always Waterloo. You may assume that the temperature is not less than -273 and not more than 200.


You are to output the name of the coldest city on a single line with no whitespace before or after the name. You may assume that there will not be more than one city which is the coldest.

Sample Input

Saskatoon -20
Toronto -2
Winnipeg -40
Vancouver 8
Halifax 0
Montreal -4
Waterloo -3

Output for Sample Input



  • -7
    mindplaysgaming  commented on Aug. 14, 2019, 3:13 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.

  • 1
    AmineHamoura03  commented on April 23, 2018, 4:10 p.m.

    Can someone tell me why I'm getting RTE on the 2nd case?

    • 4
      Iamhussam  commented on April 23, 2018, 4:28 p.m.

      The length of the array you use is 100 but there can be 10 000 cities, Think about it.

  • -4
    NickP  commented on Oct. 19, 2016, 5:12 a.m.

    How are we supposed to ascertain how many lines of input will be given? Normally the first line would be the number of lines of input, but here there is none.

    • 8
      Kirito  commented on Oct. 19, 2016, 7:58 a.m.

      and the last city is always Waterloo

  • -4
    Asuna_Orz  commented on July 31, 2015, 1:27 a.m.

    I submit my code in the judge but I get a IR result. I can't find the reason. the code runs fine when I tried it myself