CF732C.Sanatorium

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation!

Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only thing that Vasiliy has now is a card from the dining room contaning notes how many times he had a breakfast, a dinner and a supper (thus, the card contains three integers). Vasiliy could sometimes have missed some meal, for example, he could have had a breakfast and a supper, but a dinner, or, probably, at some days he haven't been at the dining room at all.

Vasiliy doesn't remember what was the time of the day when he arrived to sanatorium (before breakfast, before dinner, before supper or after supper), and the time when he left it (before breakfast, before dinner, before supper or after supper). So he considers any of these options. After Vasiliy arrived to the sanatorium, he was there all the time until he left. Please note, that it's possible that Vasiliy left the sanatorium on the same day he arrived.

According to the notes in the card, help Vasiliy determine the minimum number of meals in the dining room that he could have missed. We shouldn't count as missed meals on the arrival day before Vasiliy's arrival and meals on the departure day after he left.

瓦西里在疗养院度过了假期,回来后却完全忘记了假期的细节!

在疗养院的餐厅里,每天按顺序提供早餐、午餐和晚餐(当然,顺序固定为:早餐 → 午餐 → 晚餐)。瓦西里现在仅有一张餐厅卡片,上面记录了他总共吃了多少次早餐、午餐和晚餐(即卡片上包含三个整数)。瓦西里有时会错过某顿餐食,例如,他可能只吃了早餐和晚餐,而没吃午餐;又或者,在某些天里,他压根儿没有去餐厅。

瓦西里不记得自己抵达疗养院的具体时间(是在某天早餐前、午餐前、晚餐前,还是晚餐后),也不记得自己离开疗养院的具体时间(同样可能是某天早餐前、午餐前、晚餐前,或晚餐后)。因此,他将所有这些可能性都纳入考虑。瓦西里抵达疗养院后,便一直待在那里,直到离开为止。请注意,瓦西里有可能在抵达当天就离开疗养院。

根据卡片上的记录,请帮助瓦西里计算出他最少可能错过多少顿餐厅餐食。注意:不将抵达当日抵达前的餐食、以及离开当日离开后的餐食计入“错过”的餐食数量中。

输入格式

The only line contains three integers b, d and s (0 ≤ b, d, s ≤ 1018,  b + d + s ≥ 1) — the number of breakfasts, dinners and suppers which Vasiliy had during his vacation in the sanatorium.

唯一一行包含三个整数 bb、dd 和 ss(0 ≤ b, d, s ≤ 10180 ≤ b, d, s ≤ 10^{18},且 b + d + s ≥ 1b + d + s ≥ 1),分别表示瓦西里在疗养院度假期间所吃的早餐、午餐和晚餐的次数。

输出格式

Print single integer — the minimum possible number of meals which Vasiliy could have missed during his vacation.

输出一个整数——Vasiliy 在假期中可能错过的最少餐数。

输入输出样例

  • 输入#1

    3 2 1

    输出#1

    1
  • 输入#2

    1 0 0

    输出#2

    0
  • 输入#3

    1 1 1

    输出#3

    0
  • 输入#4

    1000000000000000000 0 1000000000000000000

    输出#4

    999999999999999999

说明/提示

In the first sample, Vasiliy could have missed one supper, for example, in case he have arrived before breakfast, have been in the sanatorium for two days (including the day of arrival) and then have left after breakfast on the third day.

In the second sample, Vasiliy could have arrived before breakfast, have had it, and immediately have left the sanatorium, not missing any meal.

In the third sample, Vasiliy could have been in the sanatorium for one day, not missing any meal.

在第一个样例中,瓦西里可能错过了一顿晚餐,例如:他在早餐前到达疗养院,在疗养院待了两天(包含到达当天),然后在第三天早餐后离开。

在第二个样例中,瓦西里可能在早餐前到达疗养院,吃完早餐后立即离开疗养院,未错过任何一餐。

在第三个样例中,瓦西里可能在疗养院待了一天,未错过任何一餐。

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

首页