题解
2025-11-13 20:28:20
发布于:广东
3阅读
0回复
0点赞
#include <bits/stdc++.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
map<int, vector<int>> students;
for (int i = 0; i < m; ++i) {
int x, y, a, b, c;
cin >> x >> y >> a >> b >> c;
if (students.find(y) == students.end()) {
students[y] = {0, 0, 0}; // 初始化
}
students[y][0] += a;
students[y][1] += b;
students[y][2] += c;
}
vector<pair<double, int>> result;
for (auto& entry : students) {
int y = entry.first;
int a_total = entry.second[0];
int b_total = entry.second[1];
int c_total = entry.second[2];
double total = (a_total * 4.0 + b_total * 4.0 + c_total * 2.0) / 10.0;
result.emplace_back(-total, y);
}
sort(result.begin(), result.end());
for (auto& item : result) {
double total = -item.first;
int y = item.second;
if (total == floor(total)) {
cout << y << " " << (int)total << endl;
} else {
cout << y << " " << total << endl;
}
}
return 0;
}
这里空空如也




有帮助,赞一个