您的位置:首页 > 其它

Greedy Gift Givers

2016-04-18 20:31 363 查看
用到的map<>

/*
ID: yiyou191
PROG: gift1
LANG: C++11
*/
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<string>
using namespace std;

const int maxn = 15;
char s[maxn][maxn];
int sum[maxn];
map<string, int> dict;
int main() {
//freopen("gift1.in", "r", stdin);
//freopen("gift1.out", "w", stdout);
int n;
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> s[i];
dict[s[i]] = i;
}
for(int i = 0; i < n; ++i) {
int x, y;
char s1[maxn], s2[maxn];
cin >> s1 >> x >> y;
for(int j = 0; j < y; ++j) {
cin >> s2;
sum[dict[s2]] += x/y;
sum[dict[s1]] -= x/y;
}
}
for(int i = 0; i < n; ++i) {
cout << s[i] << " " << sum[i] << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: