P1201-[USACO1.1]贪婪的送礼者Greedy Gift Givers

Posted asurudo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了P1201-[USACO1.1]贪婪的送礼者Greedy Gift Givers相关的知识,希望对你有一定的参考价值。

 1 #pragma GCC optimize("Ofast")
 2 #include <bits/stdc++.h>
 3 #define maxn 13003
 4 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 5 typedef long long ll;
 6 using namespace std;
 7 
 8 inline ll read()
 9 
10     ll ans = 0;
11     char ch = getchar(), last =  ;
12     while(!isdigit(ch)) last = ch, ch = getchar();
13     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - 0, ch = getchar();
14     if(last == -) ans = -ans;
15     return ans;
16 
17 inline void write(ll x)
18 
19     if(x < 0) x = -x, putchar(-);
20     if(x >= 10) write(x / 10);
21     putchar(x % 10 + 0);
22 
23 int NP;
24 map<string,int> m;
25 vector<string> v;
26 int main()
27 
28     NP = read();
29     _for(i,0,NP)
30     
31         string t;
32         cin >> t;
33         v.push_back(t);
34         m[t] = 0;
35     
36     
37     _for(i,0,NP)
38     
39         string t;
40         cin >> t;
41         auto iter = m.find(t);
42         int a,b;
43         cin >> a >> b;
44         if(b)
45             iter->second -= b*(a/b);
46         _for(i,0,b)
47         
48             string t2;
49             cin >> t2;
50             m[t2] += a/b;
51         
52     
53     
54     _for(i,0,NP)
55     
56         auto iter = m.find(v[i]);
57         cout << iter->first << " " << iter->second << endl; 
58     
59     return 0;
60 

 

以上是关于P1201-[USACO1.1]贪婪的送礼者Greedy Gift Givers的主要内容,如果未能解决你的问题,请参考以下文章

P1201 USACO1.1 贪婪的送礼者

P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers

P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers

洛谷P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers

贪婪的送礼者Greedy Gift Givers

贪婪的送礼者 USACO 培训计划中的执行错误 [关闭]