Masha has three sticks of length a, b and c

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.Input

The only line contains tree integers a, b and c (1≤a,b,c≤100

) — the lengths of sticks Masha possesses.Output

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.ExamplesInputCopy

3 4 5

OutputCopy

0

InputCopy

2 5 3

OutputCopy

1

InputCopy

100 10 10

OutputCopy

81
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int a[5];
    for(int i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    if(a[0]+a[1]>a[2])
        cout<<"0"<<endl;
    else{
        cout<<a[2]-a[0]-a[1]+1<<endl;
    }
    //system("pause");
    return 0;
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注