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; }
相关文章推荐
- 错误的ps -aux
- span无法直接设置宽度
- 20160417javaweb之servlet监听器
- java 使用DOM对XML文档进行增删改查操作
- Nightmare
- 每天一个linux命令-grep
- clientX/Y pageX/Y offsetX/Y layerX/Y screenX/Y clientHeight innerWidth...
- Retrofit+Rxjava
- 安卓015BroadcastRecever
- java的System.exit(0)和System.exit(n)
- UVA_10664_Luggage
- 冲刺第一天
- malformedurlexception: protocol not found
- Ubuntn系统时间,时区调整及同步
- NJUST1925 sequence(贪心+二分)
- ContentProvider
- Java获得不同格式的系统时间
- 【NOIP2015】IOIOI卡片占卜
- 卡尔曼滤波简介说明及其算法MATLAB实现代码
- 安卓014Fragment