QOJ.ac

QOJ

时间限制: 1 s 内存限制: 512 MB 总分: 100

#12622. 咖啡

统计

给定不同种类咖啡(拿铁、卡布奇诺等)在每种杯型(小杯、中杯、大杯)下的价格,以及一组人的订单列表,你的任务是计算每个人最终需要支付的金额。每个人需要支付的费用是其所点咖啡的费用加上配送费。配送费为 $100\$$ 除以总人数(向下取整)。

最终费用需要进行舍入处理:如果金额与最近的 $5$ 的倍数相差 $1\$$,则将其舍入到该倍数(例如 $44\$$ 和 $46\$$ 会被舍入为 $45\$$;但 $47\$$ 和 $48\$$ 不会改变)。

输入格式

输入的第一行包含一个整数 $T$,表示测试用例的数量。

每个测试用例的第一行包含两个整数 $C$ 和 $P$ ($1 \le C, P \le 100$),其中 $C$ 是咖啡种类的数量,$P$ 是人数。

接下来 $C$ 行,给出咖啡种类信息。每行包含一个字符串 $N$ 和三个整数 $S, M, L$ ($1 \le S, M, L \le 100$),其中 $N$ 是咖啡名称,$S, M, L$ 分别是小杯、中杯和大杯的价格。每种咖啡在每个测试用例中仅出现一次。

接下来 $P$ 行,给出订单列表。每行包含三个字符串 $X, Y, Z$,其中 $X$ 是人名,$Y$ 是咖啡杯型 ($Y \in \{small, medium, large\}$),$Z$ 是咖啡名称。保证所有给出的 $P$ 个名字各不相同,且每个人点的咖啡种类均存在。

咖啡名称和人名均为非空字符串,由大小写英文字母组成,长度不超过 $15$ 个字符。

输出格式

对于每个测试用例,打印 $P$ 行,每行包含两个空格分隔的值:人名和该人最终需要支付的总费用。请按照输入中给出的顺序打印人员信息。

样例

输入 1

1
3 3
cappuccino 28 34 41
latte 25 31 38
flatwhite 26 33 47
Mohammed medium cappuccino
Mostafa large latte
Ahmad small flatwhite

输出 1

Mohammed 67
Mostafa 70
Ahmad 60

说明

配送费为 $100\$$ 除以 $3$ 人,因此每人需支付 $\lfloor \frac{100}{3} \rfloor = 33\$$。

  • “Mohammed”的费用为 $34\$$(咖啡)+ $33\$$(配送费)= $67\$$,这是最终费用。
  • “Mostafa”的费用为 $38\$$(咖啡)+ $33\$$(配送费)= $71\$$,由于与最近的 $5$ 的倍数相差 $1\$$,因此舍入后的最终费用为 $70\$$。
  • “Ahmad”的费用为 $26\$$(咖啡)+ $33\$$(配送费)= $59\$$,由于与最近的 $5$ 的倍数相差 $1\$$,因此舍入后的最终费用为 $60\$$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.