模拟。

如果用$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. 从mysql8.0读取数据并形成pandas dataframe类型数据,精确定位行列式中的元素,并读取

    from pandas import * import pandas as pd from sqlalchemy import create_engine engine = create_engine ...

  2. 《Redis 设计与实现》读书笔记(三)

    多机数据库实现 十五 .复制 从服务器通过命令 slaveof 127.0.0.1 6000 成为主服务器的从服务器.然后执行复制操作,保持自己的状态和主服务器一样 1.理论 同步 成为从服务器后的同 ...

  3. Qt 工程文件(.pro)

    qmake –project 这个命令是用来生成QT的工程文件(.pro)的,这个文件是用来设置编译或者链接的变量,以便用qmake生成相对应的Makefile文件 TEMPLATE:这个变量是用来定 ...

  4. ...cURL error 60: SSL certificate problem: unable to get local issuer certificate...

    问题描述: 在做PHP爬虫的时候, 安装了 guzzle 和 dom-crawler 之后, 调用的时候出现问题, 如下 报错内容:  Fatal error: Uncaught GuzzleHttp ...

  5. 解决Spring AOP Controller 不生效

    在spring-mvc.xml文件中,进行以下配置,就可以实现在Controller中, 方法一:最简单的,在spring-mvc.xml配置文件中,添加以下语句 spring-mvc.xml < ...

  6. Homebrew是什么?怎么关闭自动更新?

    Homebrew是MacOS 的软件包管理器. 通过它可以安装.卸载.更新.查看.搜索任何想要安装的软件.如:git, node等. 安装Homebrew /usr/bin/ruby -e " ...

  7. PC打开AS400 folder

    1.首先确保在iSeriers能打开该folder  Wrklink 'QDLS'  如果出现如下错误,则需要增加user profile到Directory Entries list CPF9006 ...

  8. 我关了solution并且删掉个sln.DotSettings.user后似乎也可以了

    "Go To Definition" is disabled in Visual Studio http://social.msdn.microsoft.com/Forums/en ...

  9. BigDecimal的3个toString方法

    本文介绍BigDecimal的3个toString方法的区别. BigDecimal类有3个toString方法,分别是toEngineeringString.toPlainString和toStri ...

  10. Syn Flood 攻击

    什么是SYN Flood攻击? SYN Flood (SYN洪水) 是种典型的DoS (Denial of Service,拒绝服务) 攻击.效果就是服务器TCP连接资源耗尽,停止响应正常的TCP连接 ...