20pts, 其余RE
查看原帖
20pts, 其余RE
1108078
nothing_exe_studio楼主2023/12/2 21:32
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool compare(pair<int, string> p1, pair<int, string> p2) {
    return p1.first > p2.first;
}
int main() {
    int n;
    cin >> n;
    vector<pair<int, string>> candidates;
    for (int i = 0; i < n; i++) {
        string votes;
        cin >> votes;
        candidates.push_back(make_pair(stoi(votes), to_string(i + 1)));
    }
    sort(candidates.begin(), candidates.end(), compare);
    cout << candidates[0].second << endl;
    cout << candidates[0].first << endl;
}
2023/12/2 21:32
加载中...