P9858

· · 题解

由于不知道输入总数,可以考虑使用 while(cin>>s) 进行读入,然后就可以据此进行打擂台比较,答案是最小值。

#include<bits/stdc++.h>
using namespace std;
int main(){
    string ans, name;
    int sz = 1e7;
    while(cin >> name){
        int x;
        cin >> x;
        if(x < sz){
            sz = x;
            ans = name;
        }
    }
    cout << ans << '\n';
    return 0;
}