模拟。

如果用$map$的话,会很好写。

如果你不会$map$的话,在此小广告:https://blog.csdn.net/CQBZLYTina/article/details/80063739

 /*
ID:Starry21
LANG:C++
TASK:gift1
*/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
#define N 15
int n;
map<string,int> init;
map<string,int> rev;
string name[N];
int main()
{
//freopen("gift1.in","r",stdin);
//freopen("gift1.out","w",stdout);
scanf("%d",&n);
string a,b;
for(int i=;i<=n;i++)
cin>>name[i];
for(int i=;i<=n;i++)
{
cin>>a;
scanf("%d",&init[a]);
int k;scanf("%d",&k);
if(k==) continue;
int m=init[a]/k;
init[a]=m*k;
for(int i=;i<=k;i++)
{
cin>>b;
rev[b]+=m;
}
}
for(int i=;i<=n;i++)
{
cout<<name[i];
printf(" %d\n",rev[name[i]]-init[name[i]]);
}
return ;
}

USACO 1.1 Greedy Gift Givers的更多相关文章

  1. USACO Training Section 1.1 贪婪的送礼者Greedy Gift Givers

    P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers 题目描述 对于一群(NP个)要互送礼物的朋友,GY要确定每个人送出的钱比收到的多多少.在这一个问题中,每个人都准备了一 ...

  2. Java实现【USACO】1.1.2 贪婪的礼物送礼者 Greedy Gift Givers

    [USACO]1.1.2 贪婪的礼物送礼者 Greedy Gift Givers 题目描述 对于一群要互送礼物的朋友,你要确定每个人送出的礼物比收到的多多少(and vice versa for th ...

  3. USACO . Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...

  4. USACO Section 1.1-2 Greedy Gift Givers

    Greedy Gift Givers 贪婪的送礼者 对于一群(NP个)要互送礼物的朋友,GY要确定每个人送出的钱比收到的多多少. 在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那 ...

  5. usaco training <1.2 Greedy Gift Givers>

    题面 Task 'gift1': Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided t ...

  6. Greedy Gift Givers 贪婪的送礼者 USACO 模拟

    1002: 1.1.2 Greedy Gift Givers 贪婪的送礼者 时间限制: 1 Sec  内存限制: 128 MB提交: 9  解决: 9[提交] [状态] [讨论版] [命题人:外部导入 ...

  7. 119 - Greedy Gift Givers

     Greedy Gift Givers  The Problem This problem involves determining, for a group of gift-giving frien ...

  8. Section 1.1 Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends hasdecided to exchange gifts o ...

  9. 1.1.4 PROB Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...

随机推荐

  1. .net System.Net.Mail 之用SmtpClient发送邮件Demo

    private static bool sendMail()     {     try    {     //接收人邮箱    string SendTo = "XXXXX@163.com ...

  2. python镜像

    国内镜像列表豆瓣: http://pypi.doubanio.com/simple清华: https://pypi.tuna.tsinghua.edu.cn/simple科大: https://mir ...

  3. POJ1423 Big Number 暴力or斯特林公式??

    好吧这题很水...可是我没想到正解... 题意:求n!有多少位. 正解:斯特林公式. 直接放代码... #include<cstdio> #include<iostream> ...

  4. @EnableScheduling

  5. js面向对象学习笔记

    1.函数的定义方式 第一种定义方式 function fn1() { alert("fn1"); } alert(fn) 函数就是一个特殊的对象,是一个Function类的实例,其 ...

  6. UVA 247 Calling Circles —— (强连通分量模板题)

    第一个强连通分量的题. 题意:有一堆人,a给b打电话表示a有一条向b的边,一个强连通分量代表一个电话圈,把每个电话圈里的人在一行内输出出来. 直接上模板即可,但是要注意把string用map映射一下的 ...

  7. windos系统下使tomcat按天生成控制台日志catalina.out

    windos系统下的tomcat默认不会记录控制台catalina.out日志,只有访问日志,不便于排错 修改启动文件 1.打开bin下面的startup.bat文件,把 call "%EX ...

  8. python上下文小记

    python访问数据库是日常编程中经常使用的,一般的代码如下: 可以看出样例代码还是比较多的,有没有办法优化一下呢?有! def send_msgs(conn_id=None, **kwargs): ...

  9. cmd ora-12560协议适配器错误

    这个问题我解决了很久,其实问题的关键在于我在本机安装了一个Oracle11g数据库以及安装了一个Oracle Client,导致在使用sqlplus / as sysdba链接时出现报协议适配器的错误 ...

  10. Linux: Block Port With IPtables

    由Internet和其他网络协议识别端口号,使计算机能够与其他人进行交互.每个Linux服务器都有一个端口号(参见/ etc / services文件) Block Incoming Port The ...