/*
ID: feijunp1
PROG: gift1
LANG: C++
*/
#include <cstdio>
#include <cstring>
using namespace std;
//#define DEBUG
const int MAXN = 14;
char name[MAXN][20];
int a[MAXN], b[MAXN];
int n;
char buff[20];
int getIdx()
{
for(int i=0; i<n; i++) {
if(strcmp(buff, name[i]) == 0) return i;
}
return -1;
}
int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
#else
freopen("gift1.in", "r", stdin);
freopen("gift1.out", "w", stdout);
#endif
scanf("%d", &n);
for(int i=0; i<n; i++) {
scanf("%s", name[i]);
}
for(int i=0; i<n; i++) {
scanf("%s", buff);
int n1 = getIdx();
int s, m;
scanf("%d%d", &s, &m);
a[n1] = s;
int av;
if(m) {
b[n1] += s%m;
av = s/m;
} else {
b[n1] += s;
}
for(int i=0; i<m; i++) {
scanf("%s", buff);
b[getIdx()] += av;
}
}
for(int i=0; i<n; i++) {
printf("%s %d\n", name[i], b[i]-a[i]);
}
return 0;
}
USACO 1.1 Greedy Gift Givers
最新推荐文章于 2024-02-01 17:32:00 发布