CF105E.Lift and Throw

省选/NOI-

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given a straight half-line divided into segments of unit length, which we will call positions. The positions are numbered by positive integers that start with 1 from the end of half-line, i. e. 1, 2, 3 and so on. The distance between the positions is the absolute difference between the respective numbers.

Laharl, Etna and Flonne occupy some positions on the half-line and they want to get to the position with the largest possible number. They are originally placed in different positions.

Each of the characters can perform each of the following actions no more than once:

  • Move a certain distance.
  • Grab another character and lift him above the head.
  • Throw the lifted character a certain distance.

Each character has a movement range parameter. They can only move to free positions, assuming that distance between those positions doesn't exceed the movement range.

One character can lift another character if the distance between the two characters equals 1, and no one already holds that another character. We can assume that the lifted character moves to the same position as the person who has lifted him, and the position in which he stood before becomes free. A lifted character cannot perform any actions and the character that holds him cannot walk.

Also, each character has a throwing range parameter. It is the distance at which this character can throw the one lifted above his head. He can only throw a character to a free position, and only when there is a lifted character.

We accept the situation when one person grabs another one who in his turn has the third character in his hands. This forms a "column" of three characters. For example, Laharl can hold Etna while Etna holds Flonne. In this case, Etna and the Flonne cannot perform any actions, and Laharl can only throw Etna (together with Flonne) at some distance.

Laharl, Etna and Flonne perform actions in any order. They perform actions in turns, that is no two of them can do actions at the same time.

Determine the maximum number of position at least one of the characters can reach. That is, such maximal number x so that one of the characters can reach position x.

给你一条笔直的射线,它被划分为单位长度的线段,我们称之为“位置”。这些位置用正整数编号,编号从射线端点开始,依次为 1、2、3,依此类推。两个位置之间的距离定义为它们对应编号的绝对差值。

拉哈尔(Laharl)、艾特娜(Etna)和弗洛嫩(Flonne)初始时分别占据射线上互不相同的一些位置,他们希望到达编号尽可能大的那个位置。

每位角色至多可执行以下每种动作一次:

  • 移动一段特定的距离;
  • 抓起另一位角色并将其举过头顶;
  • 将已举起的角色向某一方向投掷一段特定的距离。

每位角色均具有一个移动范围参数:他仅能移动到空闲位置,且移动前后位置编号之差的绝对值不得超过该参数。

当两位角色之间的距离恰好为 1,且被抓住者当前未被任何人抓起时,其中一位角色才能抓起另一位角色。我们假定被抓起的角色会移动至抓起者所在的位置,而其原先所处的位置则变为空闲。被抓起的角色无法执行任何动作;而抓起者则不能行走。

此外,每位角色还具有一个投掷范围参数:即该角色能将头顶上所举角色投掷出去的最大距离。他只能将已举起的角色投掷到一个空闲位置,且仅当其头顶上确有被举起的角色时才可执行此操作。

我们允许出现一人抓起另一人、而后者又同时抓起第三人的情形,从而形成由三人叠成的“人柱”。例如,拉哈尔可抓起艾特娜,而艾特娜又同时抓起弗洛嫩。此时,艾特娜与弗洛嫩均无法执行任何动作;拉哈尔则只能将艾特娜(连同其手中的弗洛嫩)作为一个整体投掷出去。

拉哈尔、艾特娜与弗洛嫩可以以任意顺序执行动作,但动作必须轮流进行——即任意时刻至多只有一人执行动作。

请确定至少有一位角色所能到达的最大位置编号 xx,即满足存在某位角色可到达位置 xx 的最大整数 xx。

输入格式

The first line contains three integers: Laharl's position, his movement range and throwing range. The second and the third lines describe Etna's and Flonne's parameters correspondingly in the similar form. It is guaranteed that the three characters occupy distinct positions. All numbers in the input are between 1 and 10, inclusive.

第一行包含三个整数:拉哈尔的位置、移动范围和投掷范围。第二行和第三行分别以类似的形式描述伊特娜和弗洛妮的参数。保证这三个角色占据互不相同的位置。输入中的所有数字均在 1 到 10(含)之间。

输出格式

Print a single number — the maximum ordinal number of position which either Laharl, Etna or Flonne can reach.

输出一个整数——拉哈尔、伊特娜或弗洛妮所能到达的位置的最大序号。

输入输出样例

  • 输入#1

    9 3 3
    4 3 1
    2 3 3

    输出#1

    15

说明/提示

Let us explain how to reach position 15 in the sample.

Initially Laharl occupies position 9, Etna — position 4 and Flonne — position 2.

First Laharl moves to position 6.

Then Flonne moves to position 5 and grabs Etna.

Laharl grabs Flonne and throws to position 9.

Flonne throws Etna to position 12.

Etna moves to position 15.

我们来解释样例中如何到达位置 15。

初始时,拉哈尔位于位置 9,艾特娜位于位置 4,弗洛妮位于位置 2。

首先,拉哈尔移动到位置 6。

接着,弗洛妮移动到位置 5 并抓起艾特娜。

拉哈尔抓起弗洛妮,并将其投掷到位置 9。

弗洛妮将艾特娜投掷到位置 12。

艾特娜移动到位置 15。

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

首页