Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
121553 张泽辰 互送礼物 C++ 编译错误 0 0 MS 0 KB 975 2024-01-21 22:43:47

Tests(0/0):


#include <bits/stdc++.h> #include <unordered_map> using namespace std; int main() { int n; cin >> n; unordered_map<string, int> index; // 用于存储名字和对应的索引 vector<int> balance(n + 1, 0); // 使用vector代替数组 for (int i = 1; i <= n; i++) { string personName; cin >> personName; index[personName] = i; } for (int i = 1; i <= n; i++) { string giverName; int money, numFriends; cin >> giverName >> money >> numFriends; for (int j = 0; j < numFriends; j++) { string receiverName; cin >> receiverName; balance[index[receiverName]] += money / numFriends; } if (numFriends > 0) balance[index[giverName]] -= numFriends * (money / numFriends); } for (int i = 1; i <= n; i++) { cout << name[i] << " " << balance[i] << endl; } return 0; }


测评信息: