题目链接:http://cerberus.delos.com:790/usacoprob2?S=gift1&a=nR34fDHld4J
题目大意:http://blog.sina.com.cn/s/blog_63d0cab00100h1rx.html
赶脚这货考的是英语……
1 /* 2 ID: zypz457 3 LANG: C++ 4 TASK: gift1 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstdlib> 9 #include <cstring> 10 #include <map> 11 using namespace std; 12 int n; 13 map<string, int> mymap; 14 int wei[15][2]; 15 string name[20]; 16 void init() { 17 int i; 18 freopen("gift1.in", "r", stdin); 19 freopen("gift1.out", "w", stdout); 20 memset(wei, 0, sizeof(wei)); 21 scanf("%d", &n); 22 for (i = 0; i < n; ++i) { 23 cin >> name[i]; 24 mymap[name[i]] = i; 25 } 26 string str, str1; 27 while (cin >> str) { 28 int cnt, id, recid, i; 29 id = mymap[str]; 30 scanf("%d%d", &wei[id][0], &cnt); 31 for (i = 0; i < cnt;++i) { 32 cin >> str1; recid = mymap[str1]; 33 int tmp = wei[id][0] / cnt; 34 wei[id][0] = tmp * cnt; 35 wei[recid][1] += tmp; 36 } 37 } 38 } 39 void solve() { 40 int i; 41 for (i = 0; i < n; ++i) { 42 cout << name[i] << ' ' << -wei[i][0]+wei[i][1]<<'\n'; 43 } 44 } 45 int main(void) { 46 init(); 47 solve(); 48 49 return 0; 50 }
题目意思难理解,英语要好。
直接搜的翻译,开始真没看懂题意,当初感觉是有多难,看了翻译才发现……呵呵