5wa,求大佬指导,本地可以过
查看原帖
5wa,求大佬指导,本地可以过
1057068
Faded_wind123楼主2024/3/27 23:36
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Candidate {
    int number;
    int votes;
};

bool compareByVotes(const Candidate &a, const Candidate &b) {
    return a.votes < b.votes;
}

int main() {
    int n;
    cin >> n;

    vector<Candidate> candidates(n);
    for (int i = 0; i < n; ++i) {
        candidates[i].number = i + 1;
        cin >> candidates[i].votes;
    }

    sort(candidates.begin(), candidates.end(), compareByVotes);

    cout << candidates[n - 1].number << endl;

    return 0;
}
2024/3/27 23:36
加载中...