P1781 宇宙总统


// Problem: P1781 宇宙总统
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1781
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// User: Pannnn

#include 

using namespace std;

bool isBigger(string a, string b) {
    if (a.length() != b.length()) {
        return a.length() > b.length();
    } else {
        return a > b;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    string resCnt;
    int resIdx = -1;
    
    for (int i = 1; i <= n; ++i) {
        string tmp;
        cin >> tmp;
        if (isBigger(tmp, resCnt)) {
            resCnt = tmp;
            resIdx = i;
        }
    }
    cout << resIdx << endl << resCnt << endl;
    return 0;
}

相关