| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 70872 | 刘焕群 | 19选班长 | C++ | Accepted | 1 MS | 276 KB | 900 | 2024-04-20 12:06:28 |
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; // 输入学生人数 vector<int> votes(n + 1, 0); // 创建一个向量来存储每个学生的票数,初始化为0,索引从1开始 for (int i = 1; i <= n; ++i) { int a, b, c; cin >> a >> b >> c; // 输入每个学生的三票 // 更新票数 votes[a]++; votes[b]++; votes[c]++; } int maxVotes = 0; int maxStudent = 0; // 找出得票最高的学生编号 for (int i = 1; i <= n; ++i) { if (votes[i] > maxVotes) { maxVotes = votes[i]; maxStudent = i; } } cout << maxStudent << endl; // 输出得票最高的学生编号 return 0; }