贪婪的送礼者Greedy Gift Givers

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

codevs——1381 贪婪的礼物送礼者  USACO

题目描述

对于一群(NP个)要互送礼物的朋友,GY要确定每个人送出的钱比收到的多多少。在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那些将收到他的礼物的人。然而,在任何一群朋友中,有些人将送出较多的礼物(可能是因为有较多的朋友),有些人有准备了较多的钱。给出一群朋友,没有人的名字会长于 14 字符,给出每个人将花在送礼上的钱,和将收到他的礼物的人的列表,请确定每个人收到的比送出的钱多的数目。

输入输出格式

输入格式:

第 1 行: 人数NP,2<= NP<=10

第 2 行 到 第NP+1 行:这NP个在组里人的名字一个名字一行

第NP+2到最后:

这里的I段内容是这样组织的:

第一行是将会送出礼物人的名字。

第二行包含二个数字:第一个是原有的钱的数目(在0到2000的范围里),第二个 NGi 是将收到这个人礼物的人的个数 如果 NGi 是非零的, 在下面 NGi 行列出礼物的接受者的名字,一个名字一行。

输出格式:

输入输出样例

输入样例#1:

5
dave
laura
owen
vick
amr
dave
200 3
laura
owen
vick
owen
500 1
dave
amr
150 2
vick
owen
laura
0 2
amr
vick
vick
0 0

输出样例#1:

dave 302
laura 66
owen -359
vick 141
amr -150

说明

题目翻译来自NOCOW。

USACO Training Section 1.1

https://www.luogu.org/problem/show?pid=1201

今天不是很开心,所以就做几个模拟的水题吧!

代码:

时间: 2024-08-08 01:25:31

贪婪的送礼者Greedy Gift Givers的相关文章

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

题目描述 对于一群(NP个)要互送礼物的朋友,GY要确定每个人送出的钱比收到的多多少.在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那些将收到他的礼物的人.然而,在任何一群朋友中,有些人将送出较多的礼物(可能是因为有较多的朋友),有些人有准备了较多的钱.给出一群朋友,没有人的名字会长于 14 字符,给出每个人将花在送礼上的钱,和将收到他的礼物的人的列表,请确定每个人收到的比送出的钱多的数目. SilverN补充:如果钱不能按整数均分,那么余数部分会被收回,不会送出去. 输入

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

题目描述 对于一群(NP个)要互送礼物的朋友,GY要确定每个人送出的钱比收到的多多少.在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那些将收到他的礼物的人.然而,在任何一群朋友中,有些人将送出较多的礼物(可能是因为有较多的朋友),有些人有准备了较多的钱.给出一群朋友,没有人的名字会长于 14 字符,给出每个人将花在送礼上的钱,和将收到他的礼物的人的列表,请确定每个人收到的比送出的钱多的数目. 输入输出格式 输入格式: 第 1 行: 人数NP,2<= NP<=10 第 2

USACO Train 1.1.2 Greedy Gift Givers

这道题大意就是几个人互送礼物,让你求每个人的盈利. 原题给的样例数据: 5(人的个数.) =========(下面是人名,输出按照这顺序)davelauraowenvickamr ==========(下面是每个人的要给的人)dave200 3lauraowenvick ----------owen500 1dave ----------amr150 2vickowen -----------laura0 2amrvick ----------vick0 0 这题使用模拟算法就行了,就是注意输入

【USACO1.1.2】Greedy Gift Givers(map)

Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receiv

USACO 1.1 Greedy Gift Givers

Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receiv

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 of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receiv

1.1.2 Greedy Gift Givers

A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receive money from any or

USACO Greedy Gift Givers 解题心得

本题算法不难想出,但是中间还是出现了一些问题. 开始的时候是#11:Execution error,后来把普通的数组改成动态数组后问题消失. 后来又出现了Execution error: Your program had this runtime error: Illegal file open (/dev/tty). 随后google解决方案,多数都是数组开小了.遂开大数组,无效. 突然意识到很有可能是低级错误,于是检查代码. 发现写了个 for(int i = 0; i < n2 ; i++

usaco Greedy Gift Givers

/* ID: modengd1 PROG: gift1 LANG: C++ */ #include <iostream> #include<string.h> #include<stdio.h> using namespace std; char names[30][20]; int acount[30]; int counter,N; int getIndex(char name[20]) { for(int i=0;i<counter;i++) { if(st