USACO 1.1 Greedy Gift Givers
模拟。
如果用$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的更多相关文章
- USACO Training Section 1.1 贪婪的送礼者Greedy Gift Givers
P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers 题目描述 对于一群(NP个)要互送礼物的朋友,GY要确定每个人送出的钱比收到的多多少.在这一个问题中,每个人都准备了一 ...
- Java实现【USACO】1.1.2 贪婪的礼物送礼者 Greedy Gift Givers
[USACO]1.1.2 贪婪的礼物送礼者 Greedy Gift Givers 题目描述 对于一群要互送礼物的朋友,你要确定每个人送出的礼物比收到的多多少(and vice versa for th ...
- USACO . Greedy Gift Givers
Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...
- USACO Section 1.1-2 Greedy Gift Givers
Greedy Gift Givers 贪婪的送礼者 对于一群(NP个)要互送礼物的朋友,GY要确定每个人送出的钱比收到的多多少. 在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那 ...
- 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 ...
- Greedy Gift Givers 贪婪的送礼者 USACO 模拟
1002: 1.1.2 Greedy Gift Givers 贪婪的送礼者 时间限制: 1 Sec 内存限制: 128 MB提交: 9 解决: 9[提交] [状态] [讨论版] [命题人:外部导入 ...
- 119 - Greedy Gift Givers
Greedy Gift Givers The Problem This problem involves determining, for a group of gift-giving frien ...
- Section 1.1 Greedy Gift Givers
Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends hasdecided to exchange gifts o ...
- 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 ...
随机推荐
- Java8-Stream-No.06
import java.io.IOException; import java.math.BigDecimal; import java.util.Arrays; import java.util.s ...
- C# ado.net DataSet使用(五)
一.填充dataset class Program { private static string constr = "server=.;database=northwnd;integrat ...
- docker管理
查看容器名 [root@docker ~]# docker inspect -f "{{.Name}}" a2f /u1 停止/启动终止状态的容器 [root@docker ~]# ...
- SecureFX中文目录乱码问题解决方案
1.点击菜单栏中Options 2.找到General下的Configuration Paths并点击 3.在我的电脑打开 右面视图Configuration data is stored in th ...
- JavaScript实现 简易 堆
有两个原始操作用于保证插入或删除节点以后堆是一个有效的最大堆或者最小堆: shiftUp(): 如果一个节点比它的父节点大(最大堆)或者小(最小堆),那么需要将它同父节点交换位置.这样是这个节点在数组 ...
- UVAlive 7414 Squeeze the Cylinders a,b,c三种步数 搜索+最短路
题意:给你n个点(n<=50),然后有些点之间会有一条路,路是单向的,每个回合让你走a,b,c三种步数中的任意一种(a,b,c<=100),问你最少需要多少个回合才能保证一定能从1点到达n ...
- codeforces555E
Case of Computer Network CodeForces - 555E Andrewid the Android is a galaxy-known detective. Now he ...
- SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xce in position 0: invalid continuatio
点击 文档>>设置文件编码>>Unicode>>Unicode(UTF-8)
- js毫秒数转换为具体日期
[1].毫秒数转换为具体日期 function getMyDate(str) { var oDate = new Date(str), oYear = oDate.getFullYear( ...
- git push and git pull
原文链接 git push 通常对于一个本地的新建分支,例如git checkout -b develop, 在develop分支commit了代码之后,如果直接执行git push命令,develo ...