AcWing 1340. 贪婪的送礼者
原题链接
简单
作者:
Vason
,
2024-04-14 17:31:08
,
所有人可见
,
阅读 5
浅浅写一个代码
#include <iostream>
#include <cstring>
#include <string>
#include <unordered_map>
using namespace std;
const int N = 11;
string a[N];
unordered_map<string, int> h;
int n, s, m;
int main()
{
cin >> n;
for(int i = 0; i < n; i ++)
{
cin >> a[i];
h[a[i]] = 0;
}
string person, name;
for(int i = 0; i < n; i ++)
{
cin >> person >> s >> m;
for(int j = 0; j < m; j ++)
{
cin >> name;
h[name] += s / m;
h[person] -= s / m;
}
}
for(int i = 0; i < n; i ++) cout << a[i] << ' ' << h[a[i]] << endl;
return 0;
}