CF105C.Item World

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Each item in the game has a level. The higher the level is, the higher basic parameters the item has. We shall consider only the following basic parameters: attack (atk), defense (def) and resistance to different types of impact (res).

Each item belongs to one class. In this problem we will only consider three of such classes: weapon, armor, orb.

Besides, there's a whole new world hidden inside each item. We can increase an item's level travelling to its world. We can also capture the so-called residents in the Item World

Residents are the creatures that live inside items. Each resident gives some bonus to the item in which it is currently located. We will only consider residents of types: gladiator (who improves the item's atk), sentry (who improves def) and physician (who improves res).

Each item has the size parameter. The parameter limits the maximum number of residents that can live inside an item. We can move residents between items. Within one moment of time we can take some resident from an item and move it to some other item if it has a free place for a new resident. We cannot remove a resident from the items and leave outside — any of them should be inside of some item at any moment of time.

Laharl has a certain number of items. He wants to move the residents between items so as to equip himself with weapon, armor and a defensive orb. The weapon's atk should be largest possible in the end. Among all equipping patterns containing weapon's maximum atk parameter we should choose the ones where the armor’s def parameter is the largest possible. Among all such equipment patterns we should choose the one where the defensive orb would have the largest possible res parameter. Values of the parameters def and res of weapon, atk and res of armor and atk and def of orb are indifferent for Laharl.

Find the optimal equipment pattern Laharl can get.

游戏中的每件物品都有一个等级。等级越高,物品的基础属性值就越高。我们仅考虑以下三种基础属性:攻击力(atk)、防御力(def)以及对不同类型伤害的抗性(res)。

每件物品属于某一类。本题中我们只考虑以下三类:武器(weapon)、防具(armor)和法珠(orb)。

此外,每件物品内部都隐藏着一个全新的世界。我们可通过进入该物品的世界来提升其等级。我们还可以在“物品世界”中捕获所谓的“居民”。

居民是生活在物品内部的生物。每位居民都会为其当前所在的物品提供某种加成。本题中我们仅考虑以下三类居民:角斗士(gladiator,提升物品的 atk)、哨兵(sentry,提升 def)和医师(physician,提升 res)。

每件物品还有一个“容量”(size)参数,它限制了该物品内部所能容纳的居民数量上限。我们可以在不同物品之间转移居民。在任意时刻,我们可以将某位居民从一件物品中取出,并移入另一件尚有空位的物品中。我们不能将居民从物品中移出并使其处于“外部”状态——在任意时刻,每位居民都必须位于某件物品内部。

拉哈尔拥有若干件物品。他希望在这些物品之间重新分配居民,从而为自己装备一件武器、一件防具和一件防御型法珠。最终,武器的 atk 应尽可能大;在所有能使武器 atk 达到最大值的装备方案中,应选择其中防具 def 尽可能大的方案;而在所有满足前两个条件的方案中,应选择其中防御型法珠 res 尽可能大的方案。对于武器而言,其 def 和 res 值无关紧要;对于防具而言,其 atk 和 res 值无关紧要;对于法珠而言,其 atk 和 def 值无关紧要。

请找出拉哈尔所能获得的最优装备方案。

输入格式

The first line contains number n (3 ≤ n ≤ 100) — representing how many items Laharl has.

Then follow n lines. Each line contains description of an item. The description has the following form: "name class atk def res size" — the item's name, class, basic attack, defense and resistance parameters and its size correspondingly.

  • name and class are strings and atk, def, res and size are integers.
  • name consists of lowercase Latin letters and its length can range from 1 to 10, inclusive.
  • class can be "weapon", "armor" or "orb".
  • 0 ≤ atk, def, res ≤ 1000.
  • 1 ≤ size ≤ 10.

It is guaranteed that Laharl has at least one item of each class.

The next line contains an integer k (1 ≤ k ≤ 1000) — the number of residents.

Then k lines follow. Each of them describes a resident. A resident description looks like: "name type bonus home" — the resident's name, his type, the number of points the resident adds to the item's corresponding parameter and the name of the item which currently contains the resident.

  • name, type and home are strings and bonus is an integer.
  • name consists of lowercase Latin letters and its length can range from 1 to 10, inclusive.
  • type may be "gladiator", "sentry" or "physician".
  • 1 ≤ bonus ≤ 100.

It is guaranteed that the number of residents in each item does not exceed the item's size.

The names of all items and residents are pairwise different.

All words and numbers in the input are separated by single spaces.

第一行包含一个整数 nn(3≤n≤1003 \leq n \leq 100),表示拉哈尔拥有的物品数量。

接下来是 nn 行,每行描述一件物品。物品的描述格式为:_name_ _class_ _atk_ _def_ _res_ _size_ —— 分别表示该物品的名称、类别、基础攻击力、防御力、抗性参数及其尺寸。

  • _name_ 和 _class_ 是字符串,_atk_、_def_、_res_ 和 _size_ 是整数。
  • _name_ 由小写拉丁字母组成,长度在 11 到 1010(含)之间。
  • _class_ 可以是 "weapon"(武器)、"armor"(防具)或 "orb"(法珠)。
  • 0≤atk, def, res≤10000 \leq \text{atk},\ \text{def},\ \text{res} \leq 1000。
  • 1≤size≤101 \leq \text{size} \leq 10。

保证拉哈尔至少拥有一件每个类别的物品。

下一行包含一个整数 kk(1≤k≤10001 \leq k \leq 1000),表示居民的数量。

随后是 kk 行,每行描述一位居民。居民的描述格式为:_name_ _type_ _bonus_ _home_ —— 分别表示该居民的姓名、类型、其为所居住物品对应属性提供的加成点数,以及其当前所居住的物品名称。

  • _name_、_type_ 和 _home_ 是字符串,_bonus_ 是整数。
  • _name_ 由小写拉丁字母组成,长度在 11 到 1010(含)之间。
  • _type_ 可以是 "gladiator"(角斗士)、"sentry"(哨兵)或 "physician"(医师)。
  • 1≤bonus≤1001 \leq \text{bonus} \leq 100。

保证每件物品中居住的居民数量不超过该物品的尺寸。

所有物品和居民的名称两两互不相同。

输入中的所有单词与数字均以单个空格分隔。

输出格式

Print on the first line the name of the weapon in the optimal equipping pattern; then print the number of residents the weapon contains; then print the residents' names.

Print on the second and third lines in the same form the names of the armor and defensive orb as well as the residents they contain.

Use single spaces for separation.

If there are several possible solutions, print any of them.

第一行输出最优装备方案中武器的名称;然后输出该武器所包含的居民数量;再输出这些居民的姓名。

第二行和第三行以相同格式分别输出护甲和防御法球的名称,以及它们所包含的居民数量和居民姓名。

各元素之间用单个空格分隔。

若存在多种可行解,输出任意一种即可。

输入输出样例

  • 输入#1

    4
    sword weapon 10 2 3 2
    pagstarmor armor 0 15 3 1
    iceorb orb 3 2 13 2
    longbow weapon 9 1 2 1
    5
    mike gladiator 5 longbow
    bobby sentry 6 pagstarmor
    petr gladiator 7 iceorb
    teddy physician 6 sword
    blackjack sentry 8 sword

    输出#1

    sword 2 petr mike 
    pagstarmor 1 blackjack 
    iceorb 2 teddy bobby
  • 输入#2

    4
    sword weapon 10 2 3 2
    pagstarmor armor 0 15 3 1
    iceorb orb 3 2 13 2
    longbow weapon 9 1 2 1
    6
    mike gladiator 5 longbow
    bobby sentry 6 pagstarmor
    petr gladiator 7 iceorb
    teddy physician 6 sword
    blackjack sentry 8 sword
    joe physician 6 iceorb

    输出#2

    longbow 1 mike 
    pagstarmor 1 bobby 
    iceorb 2 petr joe

说明/提示

In the second sample we have no free space inside the items, therefore we cannot move the residents between them.

在第二个样例中,物品内部没有空闲空间,因此我们无法在它们之间移动居民。

输入解题思路,AI测评打分。不知道怎么写?

首页