Greedy Gift Givers

题解:

模拟。

照着他的过程(看看提示)模拟下去就行了。

{

ID:h1956701

LANG:PASCAL

PROB:gift1

}

var n,i,k,j,m:longint;

s:ansistring;

a:array[0..11]of ansistring;

b,c:array[0..11]of longint;

function find(s:ansistring):longint;

var i:longint;

begin

for i:=1 to n do

if a[i]=s then exit(i);

end;

begin

assign(input,‘gift1.in‘);

reset(input);

assign(output,‘gift1.out‘);

rewrite(output);

readln(n);

for i:=1 to n do readln(a[i]);

for i:=1 to n do

begin

readln(s);

k:=find(s);

readln(b[k],m);

for j:=1 to m do

begin

readln(s);

inc(c[find(s)],b[k] div m);

end;

if m>0 then

b[k]:=b[k]-b[k] mod m;

end;

for i:=1 to n do writeln(a[i],‘ ‘,c[i]-b[i]);

close(input);

close(output);

end.

时间: 2024-10-28 10:45:22

Greedy Gift Givers的相关文章

USACO Train 1.1.2 Greedy Gift Givers

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

贪婪的送礼者Greedy Gift Givers

洛谷——P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers codevs——1381 贪婪的礼物送礼者  USACO 题目描述 对于一群(NP个)要互送礼物的朋友,GY要确定每个人送出的钱比收到的多多少.在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那些将收到他的礼物的人.然而,在任何一群朋友中,有些人将送出较多的礼物(可能是因为有较多的朋友),有些人有准备了较多的钱.给出一群朋友,没有人的名字会长于 14 字符,给出每个人将花在送礼上的钱,和

【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++

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

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

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