CF1064A.Make a triangle!

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Masha has three sticks of length aa, bb and cc centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.

What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.

玛莎有三根长度分别为 aa、bb 和 cc 厘米的木棍。每分钟,玛莎可以任选一根木棍,将其长度增加 1 厘米。她不允许折断木棍。

为了能用这三根木棍组成一个面积为正的三角形(每根木棍作为三角形的一条边,且木棍端点需恰好位于三角形的三个顶点上),玛莎最少需要花费多少分钟来增加木棍长度?

输入格式

The only line contains tree integers aa, bb and cc (1≤a,b,c≤1001 \leq a, b, c \leq 100) — the lengths of sticks Masha possesses.

唯一的一行包含三个整数 aa、bb 和 cc(1≤a,b,c≤1001 \leq a, b, c \leq 100)——即玛莎所拥有的木棍长度。

输出格式

Print a single integer — the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.

输出一个整数——玛莎需要花费的最少分钟数,以便能够用她的木棍拼出一个面积为正的三角形。

输入输出样例

  • 输入#1

    3 4 5

    输出#1

    0
  • 输入#2

    2 5 3

    输出#2

    1
  • 输入#3

    100 10 10

    输出#3

    81

说明/提示

In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.

In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length 22 centimeter stick by one and after that form a triangle with sides 33, 33 and 55 centimeters.

In the third example, Masha can take 3333 minutes to increase one of the 1010 centimeters sticks by 3333 centimeters, and after that take 4848 minutes to increase another 1010 centimeters stick by 4848 centimeters. This way she can form a triangle with lengths 4343, 5858 and 100100 centimeters in 8181 minutes. One can show that it is impossible to get a valid triangle faster.

在第一个例子中,玛莎无需增加任何木棍的长度即可用它们组成一个三角形。

在第二个例子中,玛莎最初拥有的木棍无法构成面积为正的三角形,但她可以花费一分钟将长度为 22 厘米的木棍增加 11 厘米,之后便能用边长分别为 33、33 和 55 厘米的木棍构成一个三角形。

在第三个例子中,玛莎可以花费 3333 分钟将一根 1010 厘米长的木棍延长 3333 厘米,再花费 4848 分钟将另一根 1010 厘米长的木棍延长 4848 厘米。这样,她便能在 8181 分钟内组成一个边长分别为 4343、5858 和 100100 厘米的三角形。可以证明,无法以更短的时间得到一个合法的三角形。

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

首页