It’s Cold Here!

[CCC 2008 S1] It’s Cold Here!

题面翻译

每个城市都有不同的气温,你想要知道哪个城市的气温最低。

现在你统计了一些城市的气温 ( 1 ≤ (1 \leq (1 城市数量 ≤ 10000 \leq 10000 10000 − 273 ≤ -273 \leq 273 气温 ≤ 200 ) \leq 200) 200),请你实现一个代码,求出气温最低的城市名。

输入的最后一个城市总是 Waterloo

题目描述

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 - 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 256 256 characters in length. There is at least one city in the list, no more than 10000 10000 10000 cities, and the last city is always Waterloo. You may assume that the temperature is not less than − 273 -273 273 and not more than 200 200 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.

样例 #1

样例输入 #1

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

样例输出 #1

Winnipeg

代码内容

// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//队列
// #include <queue>//堆/优先队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    string ans, name;
    ll mx=1e7;
    while(cin>>name)
    {
        ll x;
        cin>>x;
        if(x<mx)
        {
            mx=x;
            ans=name;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Pretty Boy Fox

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值