A. Masha and Bears

Codeforces
IDCF907A
Time2000ms
Memory256MB
Difficulty
brute forceimplementation
English · Original
Chinese · Translation
Formal · Original
A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size _a_ can climb into some car with size _b_ if and only if _a_ ≤ _b_, he or she likes it if and only if he can climb into this car and 2_a_ ≥ _b_. You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars. ## Input You are given four integers _V_1, _V_2, _V_3, _V__m_(1 ≤ _V__i_ ≤ 100) — sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that _V_1 > _V_2 > _V_3. ## Output Output three integers — sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "_\-1_" (without quotes). [samples] ## Note In first test case all conditions for cars' sizes are satisfied. In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20.
一个家庭由父熊、母熊和子熊组成,他们拥有三辆车。父熊可以进入最大的车,并且他喜欢它;母熊可以进入中间的车,并且她喜欢它;子熊可以进入最小的车,并且他喜欢它。已知最大的车严格大于中间的车,中间的车严格大于最小的车。 玛莎来测试这些车。她可以进入所有车,但她只喜欢最小的车。 已知一个大小为 $a$ 的角色能够进入一辆大小为 $b$ 的车,当且仅当 $a ≤ b$;他/她喜欢这辆车,当且仅当他/她能进入这辆车且 $2a ≥ b$。 给你熊和玛莎的尺寸,请找出一组可能的车的非负整数尺寸。 你将得到四个整数 $V1$, $V2$, $V3$, $Vm$ ($1 ≤ Vi ≤ 100$) —— 分别表示父熊、母熊、子熊和玛莎的尺寸。保证 $V1 > V2 > V3$。 输出三个整数 —— 分别表示父熊的车、母熊的车和子熊的车的尺寸。 如果有多个可能的解,请输出任意一个。 如果没有解,请输出 "_-1_"(不含引号)。 在第一个测试用例中,所有关于车尺寸的条件都满足。 在第二个测试用例中,无解,因为玛莎必须能进入最小的车(因此最小车的尺寸不小于 21),但子熊必须喜欢它,因此其最大可能尺寸为 20。 ## Input 你将得到四个整数 $V1$, $V2$, $V3$, $Vm$ ($1 ≤ Vi ≤ 100$) —— 分别表示父熊、母熊、子熊和玛莎的尺寸。保证 $V1 > V2 > V3$。 ## Output 输出三个整数 —— 分别表示父熊的车、母熊的车和子熊的车的尺寸。如果有多个可能的解,请输出任意一个。如果没有解,请输出 "_-1_"(不含引号)。 [samples] ## Note 在第一个测试用例中,所有关于车尺寸的条件都满足。在第二个测试用例中,无解,因为玛莎必须能进入最小的车(因此最小车的尺寸不小于 21),但子熊必须喜欢它,因此其最大可能尺寸为 20。
**Definitions** Let $ f, m, s, a \in \mathbb{Z}^+ $ be the sizes of father bear, mother bear, son bear, and Masha, respectively, with $ f > m > s $. Let $ C_f, C_m, C_s \in \mathbb{Z}_{\geq 0} $ be the sizes of the father’s, mother’s, and son’s cars, respectively. **Constraints** 1. $ C_f > C_m > C_s $ 2. $ f \leq C_f $ and $ 2f \geq C_f $ (father likes largest car) 3. $ m \leq C_m $ and $ 2m \geq C_m $ (mother likes middle car) 4. $ s \leq C_s $ and $ 2s \geq C_s $ (son likes smallest car) 5. $ a \leq C_s $ and $ 2a \geq C_s $ (Masha likes smallest car only) **Objective** Find any integer triple $ (C_f, C_m, C_s) $ satisfying all above constraints, or output $-1$ if none exists.
Samples
Input #1
50 30 10 10
Output #1
50
30
10
Input #2
100 50 10 21
Output #2
\-1
API Response (JSON)
{
  "problem": {
    "name": "A. Masha and Bears",
    "description": {
      "content": "A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF907A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "一个家庭由父熊、母熊和子熊组成,他们拥有三辆车。父熊可以进入最大的车,并且他喜欢它;母熊可以进入中间的车,并且她喜欢它;子熊可以进入最小的车,并且他喜欢它。已知最大的车严格大于中间的车,中间的车严格大于最小的车。\n\n玛莎来测试这些车。她可以进入所有车,但她只喜欢最小的车。\n\n已知一个大小为 $a$ 的角色能够进入一辆大小为 $b$ 的车,当且仅当 $a ≤ b$;他/她喜欢这辆车,当且仅当他/她能...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ f, m, s, a \\in \\mathbb{Z}^+ $ be the sizes of father bear, mother bear, son bear, and Masha, respectively, with $ f > m > s $.  \nLet $ C_f, C_m, C_s \\in \\mathbb{Z}_{\\geq 0} $ b...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments