output
stringlengths 52
181k
| instruction
stringlengths 296
182k
|
---|---|
#include <bits/stdc++.h>
int main() {
int a, b, c, t, i, n;
scanf("%d %d %d", &a, &b, &c);
if ((a + b) > c && (a + c) > b && (b + c) > a)
t = 0;
else if ((a + b) <= c)
t = c - (a + b) + 1;
else if ((a + c) <= b)
t = b - (a + c) + 1;
else
t = a - (b + c) + 1;
printf("%d\n", t);
return 0;
}
| ### Prompt
Generate a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, t, i, n;
scanf("%d %d %d", &a, &b, &c);
if ((a + b) > c && (a + c) > b && (b + c) > a)
t = 0;
else if ((a + b) <= c)
t = c - (a + b) + 1;
else if ((a + c) <= b)
t = b - (a + c) + 1;
else
t = a - (b + c) + 1;
printf("%d\n", t);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
int arr[3];
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
int len = sizeof(arr) / sizeof(arr[0]);
sort(arr, arr + len);
if ((arr[len - 3] + arr[len - 2]) > arr[len - 1])
cout << "0" << endl;
else
cout << (arr[len - 1] - (arr[len - 3] + arr[len - 2])) + 1 << endl;
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
int arr[3];
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
int len = sizeof(arr) / sizeof(arr[0]);
sort(arr, arr + len);
if ((arr[len - 3] + arr[len - 2]) > arr[len - 1])
cout << "0" << endl;
else
cout << (arr[len - 1] - (arr[len - 3] + arr[len - 2])) + 1 << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int t[3];
int main() {
cin >> t[0] >> t[1] >> t[2];
sort(t, t + 3);
if (t[0] + t[1] >= t[2] + 1)
cout << 0;
else
cout << t[2] - t[1] - t[0] + 1;
return 0;
}
| ### Prompt
Generate a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int t[3];
int main() {
cin >> t[0] >> t[1] >> t[2];
sort(t, t + 3);
if (t[0] + t[1] >= t[2] + 1)
cout << 0;
else
cout << t[2] - t[1] - t[0] + 1;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a[3], sol;
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
int x = a[0] + a[1];
while (x <= a[2]) {
x++;
sol++;
}
cout << sol;
return 0;
}
| ### Prompt
In CPP, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[3], sol;
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
int x = a[0] + a[1];
while (x <= a[2]) {
x++;
sol++;
}
cout << sol;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
bool Trangle(double a, double b, double c) {
return a + b > c && a + c > b && b + c > a && a - b < c && a - c < b &&
b - c < a;
}
int main() {
int num[3];
int ans(0);
cin >> num[0] >> num[1] >> num[2];
{
ans = 0;
sort(num, num + 3);
while (!Trangle(num[0], num[1], num[2])) {
if (ans % 2)
num[1]++;
else
num[0]++;
ans++;
}
cout << ans << endl;
}
}
| ### Prompt
Please create a solution in cpp to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
bool Trangle(double a, double b, double c) {
return a + b > c && a + c > b && b + c > a && a - b < c && a - c < b &&
b - c < a;
}
int main() {
int num[3];
int ans(0);
cin >> num[0] >> num[1] >> num[2];
{
ans = 0;
sort(num, num + 3);
while (!Trangle(num[0], num[1], num[2])) {
if (ans % 2)
num[1]++;
else
num[0]++;
ans++;
}
cout << ans << endl;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
int n, i;
for (i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << "0"
<< "\n";
else
cout << (a[2] - a[1] - a[0]) + 1 << "\n";
return 0;
}
| ### Prompt
Develop a solution in cpp to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
int n, i;
for (i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << "0"
<< "\n";
else
cout << (a[2] - a[1] - a[0]) + 1 << "\n";
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, d, e, f, g, h = 0, i = 0;
scanf("%d%d%d", &a, &b, &c);
if (a >= b) {
if (a + b <= c) {
h = h + c - a - b + 1;
b = b + h;
}
} else if (a < b) {
if (a + b <= c) {
h = h + c - a - b + 1;
a = a + h;
}
}
if (b >= c) {
if (c + b <= a) {
h = h + a - c - b + 1;
c = c + h;
}
} else if (b < c) {
if (c + b <= a) {
h = h + a - c - b + 1;
b = b + h;
}
}
if (a + c <= b) {
h = h + b - a - c + 1;
}
printf("%d", h);
}
| ### Prompt
Develop a solution in cpp to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, d, e, f, g, h = 0, i = 0;
scanf("%d%d%d", &a, &b, &c);
if (a >= b) {
if (a + b <= c) {
h = h + c - a - b + 1;
b = b + h;
}
} else if (a < b) {
if (a + b <= c) {
h = h + c - a - b + 1;
a = a + h;
}
}
if (b >= c) {
if (c + b <= a) {
h = h + a - c - b + 1;
c = c + h;
}
} else if (b < c) {
if (c + b <= a) {
h = h + a - c - b + 1;
b = b + h;
}
}
if (a + c <= b) {
h = h + b - a - c + 1;
}
printf("%d", h);
}
``` |
#include <bits/stdc++.h>
using namespace std;
int sides[3];
int main() {
for (int i = 0; i < 3; ++i) scanf("%d", &sides[i]);
sort(sides, sides + 3);
if (sides[0] + sides[1] > sides[2])
printf("0");
else
printf("%d", sides[2] + 1 - (sides[0] + sides[1]));
return 0;
}
| ### Prompt
Develop a solution in CPP to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int sides[3];
int main() {
for (int i = 0; i < 3; ++i) scanf("%d", &sides[i]);
sort(sides, sides + 3);
if (sides[0] + sides[1] > sides[2])
printf("0");
else
printf("%d", sides[2] + 1 - (sides[0] + sides[1]));
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2005;
const long long INF = 0x3f3f3f3f;
const long long LINF = 0x1f3f3f3f3f3f3f3f;
const long long MOD = (long long)1e9 + 7;
const long long OVER_FLOW = 0xffffffff;
long long s, T, n, m, M, k, A, B, p;
long long buf[MAXN];
int main() {
ios::sync_with_stdio(false);
cin >> buf[1] >> buf[2] >> buf[3];
sort(buf + 1, buf + 1 + 3);
cout << max(0ll, buf[3] - buf[2] - buf[1] + 1) << endl;
return 0;
}
| ### Prompt
Your challenge is to write a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2005;
const long long INF = 0x3f3f3f3f;
const long long LINF = 0x1f3f3f3f3f3f3f3f;
const long long MOD = (long long)1e9 + 7;
const long long OVER_FLOW = 0xffffffff;
long long s, T, n, m, M, k, A, B, p;
long long buf[MAXN];
int main() {
ios::sync_with_stdio(false);
cin >> buf[1] >> buf[2] >> buf[3];
sort(buf + 1, buf + 1 + 3);
cout << max(0ll, buf[3] - buf[2] - buf[1] + 1) << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
map<char, int> m;
map<char, int> m1;
int main() {
long long int n = 0, d, i = 0, j = 0, l = 0, r = 0, a = 0, b = 0, c1, c2, p,
b2, s1 = 0, t = 0, t1 = 0, y = 0, x = 0, s2 = 0, c = 0;
char ch;
cin >> a >> b >> c;
vector<int> adj[100001];
int s[3];
s[0] = a;
s[1] = b;
s[2] = c;
n = 3;
sort(s, s + n);
a = s[2];
b = s[1];
c = s[0];
if (a >= (b + c)) {
while (a >= b + c) {
t++;
c++;
}
}
if (b >= a + c) {
while (b >= a + c) {
t++;
c++;
}
}
if (c >= b + a) {
while (c >= b + a) {
t++;
b++;
}
}
cout << t << endl;
return 0;
}
| ### Prompt
In Cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
map<char, int> m;
map<char, int> m1;
int main() {
long long int n = 0, d, i = 0, j = 0, l = 0, r = 0, a = 0, b = 0, c1, c2, p,
b2, s1 = 0, t = 0, t1 = 0, y = 0, x = 0, s2 = 0, c = 0;
char ch;
cin >> a >> b >> c;
vector<int> adj[100001];
int s[3];
s[0] = a;
s[1] = b;
s[2] = c;
n = 3;
sort(s, s + n);
a = s[2];
b = s[1];
c = s[0];
if (a >= (b + c)) {
while (a >= b + c) {
t++;
c++;
}
}
if (b >= a + c) {
while (b >= a + c) {
t++;
c++;
}
}
if (c >= b + a) {
while (c >= b + a) {
t++;
b++;
}
}
cout << t << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
int a[4];
int main() {
scanf("%d%d%d", &a[1], &a[2], &a[3]);
std::sort(a + 1, a + 3 + 1);
if (a[1] + a[2] > a[3]) {
printf("%d\n", 0);
} else {
printf("%d\n", a[3] - a[1] - a[2] + 1);
}
return 0;
}
| ### Prompt
Your task is to create a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int a[4];
int main() {
scanf("%d%d%d", &a[1], &a[2], &a[3]);
std::sort(a + 1, a + 3 + 1);
if (a[1] + a[2] > a[3]) {
printf("%d\n", 0);
} else {
printf("%d\n", a[3] - a[1] - a[2] + 1);
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else
cout << a[2] - a[0] - a[1] + 1;
}
| ### Prompt
Create a solution in cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else
cout << a[2] - a[0] - a[1] + 1;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
cin >> a[1] >> a[2] >> a[3];
sort(a + 1, a + 1 + 3);
cout << max(a[3] - a[1] - a[2] + 1, 0) << endl;
return 0;
}
| ### Prompt
Create a solution in Cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
cin >> a[1] >> a[2] >> a[3];
sort(a + 1, a + 1 + 3);
cout << max(a[3] - a[1] - a[2] + 1, 0) << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[4];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3, greater<int>());
if (a[0] < a[1] + a[2])
cout << "0" << endl;
else
cout << a[0] - a[1] - a[2] + 1 << endl;
return 0;
}
| ### Prompt
Create a solution in cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[4];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3, greater<int>());
if (a[0] < a[1] + a[2])
cout << "0" << endl;
else
cout << a[0] - a[1] - a[2] + 1 << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
int leg[3];
int m, n;
int x;
for (int i = 0; i < 3; i++) {
cin >> leg[i];
}
m = 0;
n = 0;
for (int i = 0; i < 3; i++) {
if (leg[i] >= m) {
n = i;
m = leg[i];
}
}
m = 0;
for (int i = 0; i < 3; i++) {
if (i == n) {
continue;
}
m += leg[i];
}
x = 0;
if (leg[n] >= m) {
x = leg[n] - m + 1;
}
cout << x;
return 0;
}
| ### Prompt
Please provide a Cpp coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
int leg[3];
int m, n;
int x;
for (int i = 0; i < 3; i++) {
cin >> leg[i];
}
m = 0;
n = 0;
for (int i = 0; i < 3; i++) {
if (leg[i] >= m) {
n = i;
m = leg[i];
}
}
m = 0;
for (int i = 0; i < 3; i++) {
if (i == n) {
continue;
}
m += leg[i];
}
x = 0;
if (leg[n] >= m) {
x = leg[n] - m + 1;
}
cout << x;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e13 + 7;
void solve();
void sieve();
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << fixed;
cout << setprecision(10);
long long int t = 1;
while (t--) solve();
return 0;
}
struct point {
long long int x, y;
point operator+(const point& a) {
point res;
res.x = x + a.x;
res.y = y + a.y;
return res;
}
point operator-(const point& a) {
point res;
res.x = x - a.x;
res.y = y - a.y;
return res;
}
long long int operator*(const point& a) {
long long int res;
res = x * a.y - y * a.x;
return res;
}
long long int operator|(const point& a) {
long long int res;
res = x * a.x + y * a.y;
return res;
}
};
long long int orientation(point p1, point p2, point p3) {
return (p1 - p2) * (p1 - p3);
}
void convexhull(vector<long long int>& v) { ; }
long double dist(point p1, point p2) {
return sqrtl((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}
void solve() {
long long int a, b, c;
cin >> a >> b >> c;
cout << max(0LL, 1 + 2 * max(a, max(b, c)) - (a + b + c));
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e13 + 7;
void solve();
void sieve();
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << fixed;
cout << setprecision(10);
long long int t = 1;
while (t--) solve();
return 0;
}
struct point {
long long int x, y;
point operator+(const point& a) {
point res;
res.x = x + a.x;
res.y = y + a.y;
return res;
}
point operator-(const point& a) {
point res;
res.x = x - a.x;
res.y = y - a.y;
return res;
}
long long int operator*(const point& a) {
long long int res;
res = x * a.y - y * a.x;
return res;
}
long long int operator|(const point& a) {
long long int res;
res = x * a.x + y * a.y;
return res;
}
};
long long int orientation(point p1, point p2, point p3) {
return (p1 - p2) * (p1 - p3);
}
void convexhull(vector<long long int>& v) { ; }
long double dist(point p1, point p2) {
return sqrtl((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}
void solve() {
long long int a, b, c;
cin >> a >> b >> c;
cout << max(0LL, 1 + 2 * max(a, max(b, c)) - (a + b + c));
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, d, t = 0;
scanf("%d %d %d", &a, &b, &c);
if (a > b) {
if (a > c) {
d = b + c;
if (d > a)
t = 0;
else {
while (1) {
t++;
d++;
if (d > a) break;
}
}
}
}
if (b > c) {
if (b > a) {
d = a + c;
if (d > b)
t = 0;
else {
while (1) {
t++;
d++;
if (d > b) break;
}
}
}
}
if (c > a) {
if (c > b) {
d = a + b;
if (d > c)
t = 0;
else {
while (1) {
t++;
d++;
if (d > c) break;
}
}
}
}
printf("%d\n", t);
return 0;
}
| ### Prompt
Develop a solution in cpp to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, d, t = 0;
scanf("%d %d %d", &a, &b, &c);
if (a > b) {
if (a > c) {
d = b + c;
if (d > a)
t = 0;
else {
while (1) {
t++;
d++;
if (d > a) break;
}
}
}
}
if (b > c) {
if (b > a) {
d = a + c;
if (d > b)
t = 0;
else {
while (1) {
t++;
d++;
if (d > b) break;
}
}
}
}
if (c > a) {
if (c > b) {
d = a + b;
if (d > c)
t = 0;
else {
while (1) {
t++;
d++;
if (d > c) break;
}
}
}
}
printf("%d\n", t);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
signed main() {
vector<unsigned> a(3);
for (unsigned& x : a) cin >> x;
sort(a.begin(), a.end());
if (a[2] < a[0] + a[1]) {
cout << 0;
exit(0);
}
cout << min(a[2] - (a[1] + a[0]),
min(a[1] - (a[2] - a[0]), a[0] - (a[2] - a[0]))) +
1;
}
| ### Prompt
Please formulate a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
signed main() {
vector<unsigned> a(3);
for (unsigned& x : a) cin >> x;
sort(a.begin(), a.end());
if (a[2] < a[0] + a[1]) {
cout << 0;
exit(0);
}
cout << min(a[2] - (a[1] + a[0]),
min(a[1] - (a[2] - a[0]), a[0] - (a[2] - a[0]))) +
1;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a(3, 0);
cin >> a[0] >> a[1] >> a[2];
sort(a.begin(), a.end());
int cnt = 0;
while (a[0] + a[1] <= a[2]) {
a[0]++;
cnt++;
if (a[0] > a[1]) {
swap(a[0], a[1]);
}
}
cout << cnt << endl;
return 0;
}
| ### Prompt
Generate a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a(3, 0);
cin >> a[0] >> a[1] >> a[2];
sort(a.begin(), a.end());
int cnt = 0;
while (a[0] + a[1] <= a[2]) {
a[0]++;
cnt++;
if (a[0] > a[1]) {
swap(a[0], a[1]);
}
}
cout << cnt << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
for (int i = 0; i < 3; i++) cin >> arr[i];
sort(arr, arr + 3);
int ans = arr[2] - arr[1] - arr[0];
cout << (ans < 0 ? 0 : ans + 1) << endl;
}
| ### Prompt
Generate a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
for (int i = 0; i < 3; i++) cin >> arr[i];
sort(arr, arr + 3);
int ans = arr[2] - arr[1] - arr[0];
cout << (ans < 0 ? 0 : ans + 1) << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int jum = a + b + c;
int maks = max(max(a, b), c);
int ans = maks - (jum - maks) + 1;
if (ans < 1)
cout << 0 << endl;
else
cout << ans << endl;
}
| ### Prompt
In Cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
int jum = a + b + c;
int maks = max(max(a, b), c);
int ans = maks - (jum - maks) + 1;
if (ans < 1)
cout << 0 << endl;
else
cout << ans << endl;
}
``` |
#include <bits/stdc++.h>
int in() {
int x = 0;
char c = getchar();
bool neg = false;
while (c != '-' && ('0' > c || c > '9')) c = getchar();
if (c == '-') neg = true, c = getchar();
while ('0' <= c && c <= '9') x = 10 * x + c - '0', c = getchar();
if (neg) x = -x;
return x;
}
void out(int x) {
if (x > 9) out(x / 10);
putchar(x % 10 + '0');
}
using namespace std;
int main() {
int kq = 0;
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
while (a[0] + a[1] + kq <= a[2]) kq++;
cout << kq;
}
| ### Prompt
Your challenge is to write a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int in() {
int x = 0;
char c = getchar();
bool neg = false;
while (c != '-' && ('0' > c || c > '9')) c = getchar();
if (c == '-') neg = true, c = getchar();
while ('0' <= c && c <= '9') x = 10 * x + c - '0', c = getchar();
if (neg) x = -x;
return x;
}
void out(int x) {
if (x > 9) out(x / 10);
putchar(x % 10 + '0');
}
using namespace std;
int main() {
int kq = 0;
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
while (a[0] + a[1] + kq <= a[2]) kq++;
cout << kq;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2]) {
cout << 0 << endl;
} else {
int cnt = 0;
while (a[0] + a[1] <= a[2]) {
a[1]++;
cnt++;
}
cout << cnt << endl;
}
return 0;
}
| ### Prompt
Develop a solution in CPP to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[5];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2]) {
cout << 0 << endl;
} else {
int cnt = 0;
while (a[0] + a[1] <= a[2]) {
a[1]++;
cnt++;
}
cout << cnt << endl;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a >= b && a >= c) {
if (b + c > a)
cout << "0";
else
cout << a - (b + c) + 1;
} else if (b >= a && b >= c) {
if (a + c > b)
cout << "0";
else
cout << b - (a + c) + 1;
} else {
if (a + b > c)
cout << "0";
else
cout << c - (a + b) + 1;
}
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a >= b && a >= c) {
if (b + c > a)
cout << "0";
else
cout << a - (b + c) + 1;
} else if (b >= a && b >= c) {
if (a + c > b)
cout << "0";
else
cout << b - (a + c) + 1;
} else {
if (a + b > c)
cout << "0";
else
cout << c - (a + b) + 1;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int arr[4], x;
int main() {
for (int i = 0; i < 3; i++) {
cin >> x;
arr[i] = x;
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3 - i - 1; j++)
if (arr[j] > arr[j + 1]) swap(arr[j], arr[j + 1]);
}
int s = (arr[2] + 1) - (arr[0] + arr[1]);
if (s <= 0)
cout << "0";
else
cout << s;
return 0;
}
| ### Prompt
Please provide a Cpp coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int arr[4], x;
int main() {
for (int i = 0; i < 3; i++) {
cin >> x;
arr[i] = x;
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3 - i - 1; j++)
if (arr[j] > arr[j + 1]) swap(arr[j], arr[j + 1]);
}
int s = (arr[2] + 1) - (arr[0] + arr[1]);
if (s <= 0)
cout << "0";
else
cout << s;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long INF = 9223372036854775807;
int md = 100000000;
const int WHITE = 0;
const int BLACK = 1;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<int> m;
int a;
cin >> a;
m.push_back(a);
cin >> a;
m.push_back(a);
cin >> a;
m.push_back(a);
sort(m.begin(), m.end());
if (m[0] + m[1] <= m[2])
cout << m[2] - m[1] - m[0] + 1 << endl;
else
cout << 0 << endl;
return 0;
}
| ### Prompt
In cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long INF = 9223372036854775807;
int md = 100000000;
const int WHITE = 0;
const int BLACK = 1;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<int> m;
int a;
cin >> a;
m.push_back(a);
cin >> a;
m.push_back(a);
cin >> a;
m.push_back(a);
sort(m.begin(), m.end());
if (m[0] + m[1] <= m[2])
cout << m[2] - m[1] - m[0] + 1 << endl;
else
cout << 0 << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, m, k;
cin >> a >> b >> c;
m = max(max(a, b), c);
k = min(min(a, b), c);
b = a + b + c - m - k;
a = m;
c = k;
m = 0;
cout << max(m, a - b - c + 1);
}
| ### Prompt
Create a solution in Cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, m, k;
cin >> a >> b >> c;
m = max(max(a, b), c);
k = min(min(a, b), c);
b = a + b + c - m - k;
a = m;
c = k;
m = 0;
cout << max(m, a - b - c + 1);
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
cout << max(0, a[2] - (a[1] + a[0]) + 1) << "\n";
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
cout << max(0, a[2] - (a[1] + a[0]) + 1) << "\n";
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int ar[3], sm = 0, i, d;
for (i = 0; i < 3; i++) scanf("%d", &ar[i]);
d = 0;
sort(ar, ar + 3);
sm = ar[0] + ar[1];
if (ar[2] >= sm) {
d = ar[2] - sm;
d++;
}
printf("%d\n", d);
return 0;
}
| ### Prompt
Please formulate a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int ar[3], sm = 0, i, d;
for (i = 0; i < 3; i++) scanf("%d", &ar[i]);
d = 0;
sort(ar, ar + 3);
sm = ar[0] + ar[1];
if (ar[2] >= sm) {
d = ar[2] - sm;
d++;
}
printf("%d\n", d);
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
long long int a, b, c, count, A, B, C;
scanf("%lld %lld %lld", &a, &b, &c);
count = 0;
while ((a + b) <= c || (b + c) <= a || (a + c) <= b) {
A = a;
B = b;
C = c;
if (A <= B && A <= C) {
a++;
count++;
}
if ((a + b) <= c || (b + c) <= a || (a + c) <= b) {
A = a;
B = b;
C = c;
if (B <= A && B <= C) {
b++;
count++;
}
}
if ((a + b) <= c || (b + c) <= a || (a + c) <= b) {
A = a;
B = b;
C = c;
if (C <= A && C <= B) {
c++;
count++;
}
}
}
printf("%lld\n", count);
return 0;
}
| ### Prompt
In CPP, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
long long int a, b, c, count, A, B, C;
scanf("%lld %lld %lld", &a, &b, &c);
count = 0;
while ((a + b) <= c || (b + c) <= a || (a + c) <= b) {
A = a;
B = b;
C = c;
if (A <= B && A <= C) {
a++;
count++;
}
if ((a + b) <= c || (b + c) <= a || (a + c) <= b) {
A = a;
B = b;
C = c;
if (B <= A && B <= C) {
b++;
count++;
}
}
if ((a + b) <= c || (b + c) <= a || (a + c) <= b) {
A = a;
B = b;
C = c;
if (C <= A && C <= B) {
c++;
count++;
}
}
}
printf("%lld\n", count);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const long long MaxN = 5;
long long n, a[MaxN], f[MaxN][13], cs;
bool kt;
void work() {
sort(a + 1, a + 4);
if (a[1] + a[2] > a[3])
cout << 0;
else
cout << a[3] - a[2] - a[1] + 1;
}
void nhap() { cin >> a[1] >> a[2] >> a[3]; }
int main() {
nhap();
work();
}
| ### Prompt
Please provide a cpp coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MaxN = 5;
long long n, a[MaxN], f[MaxN][13], cs;
bool kt;
void work() {
sort(a + 1, a + 4);
if (a[1] + a[2] > a[3])
cout << 0;
else
cout << a[3] - a[2] - a[1] + 1;
}
void nhap() { cin >> a[1] >> a[2] >> a[3]; }
int main() {
nhap();
work();
}
``` |
#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
cout << e1 << " " << e2 << " " << e3 << endl;
}
void check_time() {}
const int res = 1e5 + 5;
const long long int mod = 1e9 + 7;
int main() {
int a, b, c, maxi = 1e9;
scanf("%d %d %d", &a, &b, &c);
if (a + b > c and a + c > b and b + c > a) {
deb("0");
return 0;
}
if (a + b <= c) {
maxi = min(maxi, c - a - b + 1);
}
if (a + c <= b) {
maxi = min(maxi, b - a - c + 1);
}
if (b + c <= a) {
maxi = min(maxi, a - c - b + 1);
}
deb(maxi);
return 0;
}
| ### Prompt
Develop a solution in CPP to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
cout << e1 << " " << e2 << " " << e3 << endl;
}
void check_time() {}
const int res = 1e5 + 5;
const long long int mod = 1e9 + 7;
int main() {
int a, b, c, maxi = 1e9;
scanf("%d %d %d", &a, &b, &c);
if (a + b > c and a + c > b and b + c > a) {
deb("0");
return 0;
}
if (a + b <= c) {
maxi = min(maxi, c - a - b + 1);
}
if (a + c <= b) {
maxi = min(maxi, b - a - c + 1);
}
if (b + c <= a) {
maxi = min(maxi, a - c - b + 1);
}
deb(maxi);
return 0;
}
``` |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
long long int MOD = 1e9 + 7;
long long int ji[300005], ou[300005];
long long int brut = 1e18;
int Search_Binary(int arr[], int left, int right, int key) {
int midd = 0;
while (1) {
midd = (left + right) / 2;
if (key < arr[midd]) {
right = midd - 1;
} else if (key > arr[midd]) {
left = midd + 1;
} else {
return midd;
}
if (left > right) {
return -1;
}
}
}
int fDig(int i) {
int k;
do {
k = i;
i /= 10;
} while (i);
return k;
}
int gcd(int a, int b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int to_int(string s) {
int x;
stringstream geek(s);
geek >> x;
return x;
}
int prim_const(int x) {
vector<bool> prime(x, true);
prime[0] = prime[1] = false;
for (int i = 2; i * i <= x; ++i) {
if (prime[i]) {
if (i * 1ll * i <= x) {
for (int j = i * i; j <= x; j += i) {
prime[j] = false;
}
}
}
}
if (prime[x] == true) {
return 1;
} else {
return 0;
}
}
int arr[10000];
int key;
int main() {
cin.tie(0);
cout.tie(0);
int a, b, c;
cin >> a >> b >> c;
int minu = 0;
if (a + b <= c) {
minu += c - a - b + 1;
}
if (a + c <= b) {
minu += b - a - c + 1;
}
if (b + c <= a) {
minu += a - b - c + 1;
}
cout << minu;
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
| ### Prompt
In cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
long long int MOD = 1e9 + 7;
long long int ji[300005], ou[300005];
long long int brut = 1e18;
int Search_Binary(int arr[], int left, int right, int key) {
int midd = 0;
while (1) {
midd = (left + right) / 2;
if (key < arr[midd]) {
right = midd - 1;
} else if (key > arr[midd]) {
left = midd + 1;
} else {
return midd;
}
if (left > right) {
return -1;
}
}
}
int fDig(int i) {
int k;
do {
k = i;
i /= 10;
} while (i);
return k;
}
int gcd(int a, int b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int to_int(string s) {
int x;
stringstream geek(s);
geek >> x;
return x;
}
int prim_const(int x) {
vector<bool> prime(x, true);
prime[0] = prime[1] = false;
for (int i = 2; i * i <= x; ++i) {
if (prime[i]) {
if (i * 1ll * i <= x) {
for (int j = i * i; j <= x; j += i) {
prime[j] = false;
}
}
}
}
if (prime[x] == true) {
return 1;
} else {
return 0;
}
}
int arr[10000];
int key;
int main() {
cin.tie(0);
cout.tie(0);
int a, b, c;
cin >> a >> b >> c;
int minu = 0;
if (a + b <= c) {
minu += c - a - b + 1;
}
if (a + c <= b) {
minu += b - a - c + 1;
}
if (b + c <= a) {
minu += a - b - c + 1;
}
cout << minu;
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
``` |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long a, b, c;
cin >> a >> b >> c;
long long ans = 0;
while (a >= b + c) {
b++;
ans++;
}
while (a <= abs(b - c)) {
a++;
ans++;
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(0);
solve();
}
| ### Prompt
In cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long a, b, c;
cin >> a >> b >> c;
long long ans = 0;
while (a >= b + c) {
b++;
ans++;
}
while (a <= abs(b - c)) {
a++;
ans++;
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(0);
solve();
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, ans, n;
n = 3;
int ar[n];
for (i = 0; i < n; i++) {
cin >> ar[i];
}
sort(ar, ar + n);
if (ar[0] + ar[1] > ar[2]) {
cout << 0 << "\n";
} else {
ans = ar[2] - (ar[0] + ar[1]);
cout << ans + 1 << "\n";
}
return 0;
}
| ### Prompt
Your challenge is to write a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, ans, n;
n = 3;
int ar[n];
for (i = 0; i < n; i++) {
cin >> ar[i];
}
sort(ar, ar + n);
if (ar[0] + ar[1] > ar[2]) {
cout << 0 << "\n";
} else {
ans = ar[2] - (ar[0] + ar[1]);
cout << ans + 1 << "\n";
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long a[3], b, c;
cin >> a[0] >> a[1] >> a[2];
b = a[1];
c = a[2];
if (a[0] + b > c && a[0] + c > b && c + b > a[0]) return cout << 0, 0;
sort(a, a + 3);
long long ans = 0;
b = a[0];
c = a[1];
while (1) {
b++;
ans++;
if (b + c > a[2]) return cout << ans, 0;
c++;
ans++;
if (b + c > a[2]) return cout << ans, 0;
}
}
| ### Prompt
Your task is to create a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long a[3], b, c;
cin >> a[0] >> a[1] >> a[2];
b = a[1];
c = a[2];
if (a[0] + b > c && a[0] + c > b && c + b > a[0]) return cout << 0, 0;
sort(a, a + 3);
long long ans = 0;
b = a[0];
c = a[1];
while (1) {
b++;
ans++;
if (b + c > a[2]) return cout << ans, 0;
c++;
ans++;
if (b + c > a[2]) return cout << ans, 0;
}
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, x, y, z, dif;
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
if (a >= b && a >= c) {
x = a;
y = b;
z = c;
} else if (b >= c && b >= a) {
x = b;
y = a;
z = c;
} else if (c >= b && c >= a) {
x = c;
y = b;
z = a;
}
if (y + z <= x) {
dif = x - y - z;
printf("%d", dif + 1);
} else
printf("0");
}
| ### Prompt
Your challenge is to write a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, x, y, z, dif;
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
if (a >= b && a >= c) {
x = a;
y = b;
z = c;
} else if (b >= c && b >= a) {
x = b;
y = a;
z = c;
} else if (c >= b && c >= a) {
x = c;
y = b;
z = a;
}
if (y + z <= x) {
dif = x - y - z;
printf("%d", dif + 1);
} else
printf("0");
}
``` |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int arr[MAXN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
cout << max(0, arr[2] + 1 - (arr[0] + arr[1])) << "\n";
return 0;
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int arr[MAXN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
cout << max(0, arr[2] + 1 - (arr[0] + arr[1])) << "\n";
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int sides[3], addTime;
for (int i = 0; i < 3; i++) {
cin >> sides[i];
}
sort(sides, sides + 3);
if (sides[0] + sides[1] > sides[2]) {
cout << "0" << endl;
} else {
addTime = (sides[2] + 1) - (sides[0] + sides[1]);
cout << addTime << endl;
}
return 0;
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int sides[3], addTime;
for (int i = 0; i < 3; i++) {
cin >> sides[i];
}
sort(sides, sides + 3);
if (sides[0] + sides[1] > sides[2]) {
cout << "0" << endl;
} else {
addTime = (sides[2] + 1) - (sides[0] + sides[1]);
cout << addTime << endl;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a < b) swap(a, b);
if (b < c) swap(b, c);
cout << max(a + 1 - b - c, max(b + 1 - a - c, max(c + 1 - b - a, 0))) << endl;
return 0;
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a < b) swap(a, b);
if (b < c) swap(b, c);
cout << max(a + 1 - b - c, max(b + 1 - a - c, max(c + 1 - b - a, 0))) << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
while (~scanf("%d%d%d", &a, &b, &c)) {
int a1 = b + c, b1 = a + c, c1 = a + b;
if (a1 > a && b1 > b && c1 > c)
printf("0\n");
else {
int minn = 9999999;
minn = minn > (a1 - a) ? (a1 - a) : minn;
minn = minn > (b1 - b) ? (b1 - b) : minn;
minn = minn > (c1 - c) ? (c1 - c) : minn;
printf("%d\n", -minn + 1);
}
}
return 0;
}
| ### Prompt
Create a solution in cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
while (~scanf("%d%d%d", &a, &b, &c)) {
int a1 = b + c, b1 = a + c, c1 = a + b;
if (a1 > a && b1 > b && c1 > c)
printf("0\n");
else {
int minn = 9999999;
minn = minn > (a1 - a) ? (a1 - a) : minn;
minn = minn > (b1 - b) ? (b1 - b) : minn;
minn = minn > (c1 - c) ? (c1 - c) : minn;
printf("%d\n", -minn + 1);
}
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
const int MX = 100005, infi = 1000000000, mod = 1000000007;
int n, v[3];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> v[0] >> v[1] >> v[2];
sort(v, v + 3);
cout << max(0, v[2] - (v[0] + v[1]) + 1);
return 0;
}
| ### Prompt
Create a solution in Cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const int MX = 100005, infi = 1000000000, mod = 1000000007;
int n, v[3];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> v[0] >> v[1] >> v[2];
sort(v, v + 3);
cout << max(0, v[2] - (v[0] + v[1]) + 1);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long i, arr[3];
for (i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
if ((arr[0] + arr[1]) > arr[2])
cout << "0";
else
cout << (arr[2] - (arr[0] + arr[1])) + 1;
return 0;
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long i, arr[3];
for (i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
if ((arr[0] + arr[1]) > arr[2])
cout << "0";
else
cout << (arr[2] - (arr[0] + arr[1])) + 1;
return 0;
}
``` |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void io() {}
long long fast_exp(long long base, int exp, int m) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1) {
res = (res * base) % m;
}
base = (base * base) % m;
exp /= 2;
}
return res % m;
}
long long arr[200005];
long long val[200005];
long long siz[200005];
map<long long, long long> mp;
long long ans, cnt, tmp;
long long vis[200005];
vector<long long> adj[200005];
long long dp[2001][2001];
long long n, m, k;
int main() {
io();
ios ::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t = 0;
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[2] - arr[1] - arr[0] < 0) {
cout << 0 << '\n';
return 0;
}
cout << arr[2] - arr[1] - arr[0] + 1 << '\n';
}
| ### Prompt
Generate a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void io() {}
long long fast_exp(long long base, int exp, int m) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1) {
res = (res * base) % m;
}
base = (base * base) % m;
exp /= 2;
}
return res % m;
}
long long arr[200005];
long long val[200005];
long long siz[200005];
map<long long, long long> mp;
long long ans, cnt, tmp;
long long vis[200005];
vector<long long> adj[200005];
long long dp[2001][2001];
long long n, m, k;
int main() {
io();
ios ::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t = 0;
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[2] - arr[1] - arr[0] < 0) {
cout << 0 << '\n';
return 0;
}
cout << arr[2] - arr[1] - arr[0] + 1 << '\n';
}
``` |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int a[5];
cin >> a[1] >> a[2] >> a[3];
sort(a + 1, a + 3 + 1);
if (a[1] + a[2] > a[3])
cout << 0 << endl;
else
cout << a[3] + 1 - a[1] - a[2] << endl;
}
int main() {
solve();
return 0;
}
| ### Prompt
Generate a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
int a[5];
cin >> a[1] >> a[2] >> a[3];
sort(a + 1, a + 3 + 1);
if (a[1] + a[2] > a[3])
cout << 0 << endl;
else
cout << a[3] + 1 - a[1] - a[2] << endl;
}
int main() {
solve();
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else if (a[0] + a[1] == a[2])
cout << 1;
else
cout << (a[2] - (a[0] + a[1])) + 1;
return 0;
}
| ### Prompt
Your task is to create a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else if (a[0] + a[1] == a[2])
cout << 1;
else
cout << (a[2] - (a[0] + a[1])) + 1;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
int n = sizeof(a) / sizeof(a[0]);
sort(a, a + n);
if (a[0] + a[1] > a[2]) {
cout << "0";
} else if (a[0] + a[1] <= a[2]) {
cout << a[2] - (a[0] + a[1]) + 1;
}
}
| ### Prompt
Please formulate a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
int n = sizeof(a) / sizeof(a[0]);
sort(a, a + n);
if (a[0] + a[1] > a[2]) {
cout << "0";
} else if (a[0] + a[1] <= a[2]) {
cout << a[2] - (a[0] + a[1]) + 1;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
int val = arr[0] + arr[1];
if (val <= arr[2]) {
int res = arr[2] - val + 1;
cout << res << endl;
} else
cout << "0" << endl;
}
| ### Prompt
Develop a solution in Cpp to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
for (int i = 0; i < 3; i++) {
cin >> arr[i];
}
sort(arr, arr + 3);
int val = arr[0] + arr[1];
if (val <= arr[2]) {
int res = arr[2] - val + 1;
cout << res << endl;
} else
cout << "0" << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int y = a[2] + 1 - a[0] - a[1];
cout << max(0, y);
return 0;
}
| ### Prompt
In Cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int y = a[2] + 1 - a[0] - a[1];
cout << max(0, y);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a < b) swap(a, b);
if (a < c) swap(a, c);
if (b < c) swap(b, c);
if (b + c <= a)
cout << a - c - b + 1;
else
cout << 0;
}
| ### Prompt
Construct a CPP code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a < b) swap(a, b);
if (a < c) swap(a, c);
if (b < c) swap(b, c);
if (b + c <= a)
cout << a - c - b + 1;
else
cout << 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (a < b) swap(a, b);
if (a < c) swap(a, c);
int ans;
if (b + c > a)
ans = 0;
else
ans = a - b - c + 1;
printf("%d\n", ans);
return 0;
}
| ### Prompt
Construct a CPP code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (a < b) swap(a, b);
if (a < c) swap(a, c);
int ans;
if (b + c > a)
ans = 0;
else
ans = a - b - c + 1;
printf("%d\n", ans);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
inline int mul(int a, int b) { return int(a * 1ll * b % 998244353); }
inline int norm(int a) {
if (a >= 998244353) a -= 998244353;
if (a < 0) a += 998244353;
return a;
}
inline int binPow(int a, int k) {
int ans = 1;
while (k > 0) {
if (k & 1) ans = mul(ans, a);
a = mul(a, a);
k >>= 1;
}
return ans;
}
inline int subtract(int a, int b) { return norm(a - b); }
inline int sum(int a, int b) { return int((a + b) % 998244353); }
inline int inv(int a) { return binPow(a, 998244353 - 2); }
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
vector<int> a(3);
for (int i = 0; i < 3; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
cout << max(0, a[2] - a[1] - a[0] + 1);
return 0;
}
| ### Prompt
Generate a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
inline int mul(int a, int b) { return int(a * 1ll * b % 998244353); }
inline int norm(int a) {
if (a >= 998244353) a -= 998244353;
if (a < 0) a += 998244353;
return a;
}
inline int binPow(int a, int k) {
int ans = 1;
while (k > 0) {
if (k & 1) ans = mul(ans, a);
a = mul(a, a);
k >>= 1;
}
return ans;
}
inline int subtract(int a, int b) { return norm(a - b); }
inline int sum(int a, int b) { return int((a + b) % 998244353); }
inline int inv(int a) { return binPow(a, 998244353 - 2); }
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
vector<int> a(3);
for (int i = 0; i < 3; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
cout << max(0, a[2] - a[1] - a[0] + 1);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3], r = 0;
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[0] + arr[1] > arr[2]) {
cout << "0";
} else {
cout << arr[2] - (arr[0] + arr[1]) + 1;
}
}
| ### Prompt
Your task is to create a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3], r = 0;
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[0] + arr[1] > arr[2]) {
cout << "0";
} else {
cout << arr[2] - (arr[0] + arr[1]) + 1;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, ctr = 0;
cin >> a >> b >> c;
while (a + b <= c) {
ctr++;
a > b ? a++ : b++;
}
while (b + c <= a) {
ctr++;
b > c ? b++ : c++;
}
while (a + c <= b) {
ctr++;
a > c ? a++ : c++;
}
cout << ctr << "\n";
}
| ### Prompt
Please provide a CPP coded solution to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, ctr = 0;
cin >> a >> b >> c;
while (a + b <= c) {
ctr++;
a > b ? a++ : b++;
}
while (b + c <= a) {
ctr++;
b > c ? b++ : c++;
}
while (a + c <= b) {
ctr++;
a > c ? a++ : c++;
}
cout << ctr << "\n";
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int sum = 0;
for (int i = 0;; i++) {
if (a[1] + a[0] > a[2])
break;
else {
sum++;
a[1] += 1;
}
}
cout << sum;
return 0;
}
| ### Prompt
Your task is to create a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int sum = 0;
for (int i = 0;; i++) {
if (a[1] + a[0] > a[2])
break;
else {
sum++;
a[1] += 1;
}
}
cout << sum;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[0] + arr[1] > arr[2]) {
cout << 0;
} else {
cout << arr[2] - arr[1] - arr[0] + 1;
}
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr + 3);
if (arr[0] + arr[1] > arr[2]) {
cout << 0;
} else {
cout << arr[2] - arr[1] - arr[0] + 1;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[] = {0, 0, 0};
for (int i = 0; i < 3; i++) cin >> arr[i];
sort(arr, arr + 3);
if (arr[2] < (arr[0] + arr[1]))
cout << "0";
else
cout << (1 + (arr[2] - (arr[0] + arr[1])));
return 0;
}
| ### Prompt
In CPP, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[] = {0, 0, 0};
for (int i = 0; i < 3; i++) cin >> arr[i];
sort(arr, arr + 3);
if (arr[2] < (arr[0] + arr[1]))
cout << "0";
else
cout << (1 + (arr[2] - (arr[0] + arr[1])));
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a[10], b, c, i, j;
for (i = 0; i < 3; i++) scanf("%d", &a[i]);
for (i = 0; i < 3; i++) {
for (j = i + 1; j < 3; j++) {
if (a[i] > a[j]) {
b = a[i];
a[i] = a[j];
a[j] = b;
}
}
}
int p = a[0], q = a[1], r = a[2], z;
if ((p + q) <= r) {
z = r - (p + q) + 1;
printf("%d\n", z);
} else
printf("0\n");
}
| ### Prompt
Develop a solution in Cpp to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a[10], b, c, i, j;
for (i = 0; i < 3; i++) scanf("%d", &a[i]);
for (i = 0; i < 3; i++) {
for (j = i + 1; j < 3; j++) {
if (a[i] > a[j]) {
b = a[i];
a[i] = a[j];
a[j] = b;
}
}
}
int p = a[0], q = a[1], r = a[2], z;
if ((p + q) <= r) {
z = r - (p + q) + 1;
printf("%d\n", z);
} else
printf("0\n");
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a, b, c, A, B, C;
string s;
int main() {
cin >> a >> b >> c;
A = max(a, b);
B = max(b, c);
C = max(A, B);
if (C == a) {
if (a < b + c) {
cout << 0;
return 0;
} else {
cout << a - b - c + 1;
return 0;
}
}
if (C == b) {
if (b < a + c) {
cout << 0;
return 0;
} else {
cout << b - a - c + 1;
return 0;
}
}
if (C == c) {
if (c < a + b) {
cout << 0;
return 0;
} else {
cout << c - a - b + 1;
return 0;
}
}
}
| ### Prompt
Please formulate a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a, b, c, A, B, C;
string s;
int main() {
cin >> a >> b >> c;
A = max(a, b);
B = max(b, c);
C = max(A, B);
if (C == a) {
if (a < b + c) {
cout << 0;
return 0;
} else {
cout << a - b - c + 1;
return 0;
}
}
if (C == b) {
if (b < a + c) {
cout << 0;
return 0;
} else {
cout << b - a - c + 1;
return 0;
}
}
if (C == c) {
if (c < a + b) {
cout << 0;
return 0;
} else {
cout << c - a - b + 1;
return 0;
}
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 3;
const long long Linf = 1e18;
int main() {
ios_base::sync_with_stdio(false);
int x[3];
cin >> x[0] >> x[1] >> x[2];
sort(x, x + 3);
int ans = (x[2] >= x[0] + x[1] ? x[2] - x[1] - x[0] + 1 : 0);
cout << ans << '\n';
return 0;
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 3;
const long long Linf = 1e18;
int main() {
ios_base::sync_with_stdio(false);
int x[3];
cin >> x[0] >> x[1] >> x[2];
sort(x, x + 3);
int ans = (x[2] >= x[0] + x[1] ? x[2] - x[1] - x[0] + 1 : 0);
cout << ans << '\n';
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a, b, c, Count = 1;
int main() {
cin >> a >> b >> c;
if ((a + b > c) && (a + c > b) && (b + c > a)) {
cout << 0 << endl;
return 0;
}
while ((a + b < c) || (a + c < b) || (b + c < a)) {
++Count;
if (a + b < c) {
if (a < b)
a++;
else
b++;
} else if (a + c < b) {
if (a < c)
a++;
else
c++;
} else if (b + c < a) {
if (b < c)
b++;
else
c++;
}
}
cout << Count << endl;
return 0;
}
| ### Prompt
Your task is to create a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a, b, c, Count = 1;
int main() {
cin >> a >> b >> c;
if ((a + b > c) && (a + c > b) && (b + c > a)) {
cout << 0 << endl;
return 0;
}
while ((a + b < c) || (a + c < b) || (b + c < a)) {
++Count;
if (a + b < c) {
if (a < b)
a++;
else
b++;
} else if (a + c < b) {
if (a < c)
a++;
else
c++;
} else if (b + c < a) {
if (b < c)
b++;
else
c++;
}
}
cout << Count << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int n[3], cnt;
int main() {
for (int i = 0; i < 3; i++) {
cin >> n[i];
}
sort(n, n + 3);
if (n[0] + n[1] > n[2]) {
cout << 0;
return 0;
} else {
while (n[0] + n[1] <= n[2]) {
n[1]++;
cnt++;
}
}
cout << cnt;
}
| ### Prompt
In CPP, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int n[3], cnt;
int main() {
for (int i = 0; i < 3; i++) {
cin >> n[i];
}
sort(n, n + 3);
if (n[0] + n[1] > n[2]) {
cout << 0;
return 0;
} else {
while (n[0] + n[1] <= n[2]) {
n[1]++;
cnt++;
}
}
cout << cnt;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
int cnt = 0;
while (a[0] + a[1] <= a[2]) {
cnt++, a[0]++;
}
cout << cnt << endl;
return 0;
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
int cnt = 0;
while (a[0] + a[1] <= a[2]) {
cnt++, a[0]++;
}
cout << cnt << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, f, i;
cin >> a >> b >> c;
d = a + b;
e = b + c;
f = a + c;
int sum1 = 0, sum2 = 0, sum3 = 0;
for (i = 0; i < 100; i++) {
if (d > c)
break;
else {
sum1++;
d++;
}
}
for (i = 0; i < 100; i++) {
if (e > a)
break;
else {
sum2++;
e++;
}
}
for (i = 0; i < 100; i++) {
if (f > b)
break;
else {
sum3++;
f++;
}
}
int res = sum1 + sum2 + sum3;
cout << res << endl;
return 0;
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, f, i;
cin >> a >> b >> c;
d = a + b;
e = b + c;
f = a + c;
int sum1 = 0, sum2 = 0, sum3 = 0;
for (i = 0; i < 100; i++) {
if (d > c)
break;
else {
sum1++;
d++;
}
}
for (i = 0; i < 100; i++) {
if (e > a)
break;
else {
sum2++;
e++;
}
}
for (i = 0; i < 100; i++) {
if (f > b)
break;
else {
sum3++;
f++;
}
}
int res = sum1 + sum2 + sum3;
cout << res << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
int ans = 0;
cin >> a >> b >> c;
while (a + b <= c || b + c <= a || a + c <= b) {
if (a + b <= c) {
if (a < b) {
a++;
} else {
b++;
}
ans++;
}
if (b + c <= a) {
if (b < c) {
b++;
} else {
c++;
}
ans++;
}
if (a + c <= b) {
if (a < c) {
a++;
} else {
c++;
}
ans++;
}
}
cout << ans;
return 0;
}
| ### Prompt
Create a solution in cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
int ans = 0;
cin >> a >> b >> c;
while (a + b <= c || b + c <= a || a + c <= b) {
if (a + b <= c) {
if (a < b) {
a++;
} else {
b++;
}
ans++;
}
if (b + c <= a) {
if (b < c) {
b++;
} else {
c++;
}
ans++;
}
if (a + c <= b) {
if (a < c) {
a++;
} else {
c++;
}
ans++;
}
}
cout << ans;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
int a, b, c;
cin >> a >> b >> c;
if ((a + b > c) && (b + c > a) && (c + a > b))
cout << "0\n";
else {
v.push_back(a);
v.push_back(b);
v.push_back(c);
sort(v.begin(), v.end());
a = v[0];
b = v[1];
c = v[2];
cout << (c - (a + b) + 1) << "\n";
}
}
| ### Prompt
In CPP, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
int a, b, c;
cin >> a >> b >> c;
if ((a + b > c) && (b + c > a) && (c + a > b))
cout << "0\n";
else {
v.push_back(a);
v.push_back(b);
v.push_back(c);
sort(v.begin(), v.end());
a = v[0];
b = v[1];
c = v[2];
cout << (c - (a + b) + 1) << "\n";
}
}
``` |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
std::pair<int, int> DR[] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1},
{-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
int a[3];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cerr.tie(0);
cout.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
return cout << max(0, a[2] - a[0] - a[1] + 1), 0;
}
| ### Prompt
Generate a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
std::pair<int, int> DR[] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1},
{-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
int a[3];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cerr.tie(0);
cout.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
return cout << max(0, a[2] - a[0] - a[1] + 1), 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else
cout << a[2] - a[0] - a[1] + 1;
return 0;
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2])
cout << 0;
else
cout << a[2] - a[0] - a[1] + 1;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
for (int i = 0; i < 3; i++) {
cin >> a[i];
}
sort(a, a + 3);
if (a[2] < a[0] + a[1]) {
cout << 0 << endl;
} else {
cout << a[2] - a[1] - a[0] + 1 << endl;
}
return 0;
}
| ### Prompt
Generate a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
for (int i = 0; i < 3; i++) {
cin >> a[i];
}
sort(a, a + 3);
if (a[2] < a[0] + a[1]) {
cout << 0 << endl;
} else {
cout << a[2] - a[1] - a[0] + 1 << endl;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2]) {
cout << 0;
return 0;
}
cout << a[2] - (a[1] + a[0]) + 1;
return 0;
}
| ### Prompt
Please create a solution in Cpp to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long a[3];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
if (a[0] + a[1] > a[2]) {
cout << 0;
return 0;
}
cout << a[2] - (a[1] + a[0]) + 1;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int T = 1;
while (T--) {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
cout << max(0, a[2] - a[1] - a[0] + 1);
}
return 0;
}
| ### Prompt
In cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int T = 1;
while (T--) {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
cout << max(0, a[2] - a[1] - a[0] + 1);
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long ans;
int main() {
vector<int> a(3);
for (size_t i = 0; i < 3; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
cout << ((a[1] + a[0] > a[2]) ? 0 : (-a[1] - a[0] + a[2] + 1));
}
| ### Prompt
Your challenge is to write a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long ans;
int main() {
vector<int> a(3);
for (size_t i = 0; i < 3; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
cout << ((a[1] + a[0] > a[2]) ? 0 : (-a[1] - a[0] + a[2] + 1));
}
``` |
#include <bits/stdc++.h>
using namespace std;
bool checkValidity(int a, int b, int c) {
if (a + b <= c || a + c <= b || b + c <= a)
return false;
else
return true;
}
int maximum(int a, int b, int c) {
int max = (a < b) ? b : a;
return ((max < c) ? c : max);
}
int main() {
long long a, b, c, d;
cin >> a >> b >> c;
if (checkValidity(a, b, c))
cout << 0;
else {
d = maximum(a, b, c);
if (a == d)
cout << (a - (b + c) + 1);
else if (b == d)
cout << (b - (a + c) + 1);
else
cout << (c - (a + b) + 1);
}
return 0;
}
| ### Prompt
Your challenge is to write a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
bool checkValidity(int a, int b, int c) {
if (a + b <= c || a + c <= b || b + c <= a)
return false;
else
return true;
}
int maximum(int a, int b, int c) {
int max = (a < b) ? b : a;
return ((max < c) ? c : max);
}
int main() {
long long a, b, c, d;
cin >> a >> b >> c;
if (checkValidity(a, b, c))
cout << 0;
else {
d = maximum(a, b, c);
if (a == d)
cout << (a - (b + c) + 1);
else if (b == d)
cout << (b - (a + c) + 1);
else
cout << (c - (a + b) + 1);
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, ans;
cin >> a >> b >> c;
int a1[3];
a1[0] = a;
a1[1] = b;
a1[2] = c;
sort(a1, a1 + 3);
if (a1[0] + a1[1] > a1[2])
ans = 0;
else
ans = a1[2] - a1[0] - a1[1] + 1;
cout << ans;
return 0;
}
| ### Prompt
Please formulate a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, ans;
cin >> a >> b >> c;
int a1[3];
a1[0] = a;
a1[1] = b;
a1[2] = c;
sort(a1, a1 + 3);
if (a1[0] + a1[1] > a1[2])
ans = 0;
else
ans = a1[2] - a1[0] - a1[1] + 1;
cout << ans;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int code() {
long long int a, b, c;
cin >> a >> b >> c;
long long int aa = max(a, b);
aa = max(aa, c);
long long int sum = a + b + c - aa;
long long int ans = ((sum - aa <= 0) ? aa - sum + 1 : 0);
cout << ans << endl;
return 0;
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
code();
}
| ### Prompt
Create a solution in cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int code() {
long long int a, b, c;
cin >> a >> b >> c;
long long int aa = max(a, b);
aa = max(aa, c);
long long int sum = a + b + c - aa;
long long int ans = ((sum - aa <= 0) ? aa - sum + 1 : 0);
cout << ans << endl;
return 0;
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
code();
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, x, y, z;
cin >> a >> b >> c;
int q[3] = {a, b, c};
sort(q, q + 3, greater<int>());
x = q[0];
y = q[1];
z = q[2];
int t = z + y;
if (t > x)
cout << 0;
else {
cout << (x - t) + 1;
}
}
| ### Prompt
Your task is to create a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, x, y, z;
cin >> a >> b >> c;
int q[3] = {a, b, c};
sort(q, q + 3, greater<int>());
x = q[0];
y = q[1];
z = q[2];
int t = z + y;
if (t > x)
cout << 0;
else {
cout << (x - t) + 1;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
vector<int> v(3);
cin >> v[0] >> v[1] >> v[2];
sort(v.begin(), v.end());
int ans = max(0, v[2] - v[1] - v[0] + 1);
cout << ans << endl;
return 0;
}
| ### Prompt
Develop a solution in Cpp to the problem described below:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
vector<int> v(3);
cin >> v[0] >> v[1] >> v[2];
sort(v.begin(), v.end());
int ans = max(0, v[2] - v[1] - v[0] + 1);
cout << ans << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
unsigned int x[3], i, t, n = 0;
for (i = 0; i < 3; i++) scanf("%u", &x[i]);
if (x[2] < x[1]) {
t = x[1];
x[1] = x[2];
x[2] = t;
}
if (x[2] < x[0]) {
t = x[0];
x[0] = x[2];
x[2] = t;
}
while (!(x[0] + x[1] > x[2])) {
x[2]--;
n++;
}
printf("%u", n);
return 0;
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
unsigned int x[3], i, t, n = 0;
for (i = 0; i < 3; i++) scanf("%u", &x[i]);
if (x[2] < x[1]) {
t = x[1];
x[1] = x[2];
x[2] = t;
}
if (x[2] < x[0]) {
t = x[0];
x[0] = x[2];
x[2] = t;
}
while (!(x[0] + x[1] > x[2])) {
x[2]--;
n++;
}
printf("%u", n);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
vector<int> Length(3);
for (int i = 0; i < 3; ++i) {
scanf("%d", &Length[i]);
}
sort(Length.begin(), Length.end());
printf("%d\n", max(0, Length[2] - (Length[0] + Length[1]) + 1));
return 0;
}
| ### Prompt
Create a solution in Cpp for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
vector<int> Length(3);
for (int i = 0; i < 3; ++i) {
scanf("%d", &Length[i]);
}
sort(Length.begin(), Length.end());
printf("%d\n", max(0, Length[2] - (Length[0] + Length[1]) + 1));
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y / 2;
x = (x * x) % p;
}
return res;
}
void solve() {
long long int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
long long int x = a[0] + a[1] - a[2];
if (x > 0) {
cout << 0 << "\n";
return;
} else {
cout << a[2] + 1 - (a[0] + a[1]) << "\n";
return;
}
}
int main() {
long long int t = 1;
while (t--) {
solve();
}
return 0;
}
| ### Prompt
Construct a Cpp code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y / 2;
x = (x * x) % p;
}
return res;
}
void solve() {
long long int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
long long int x = a[0] + a[1] - a[2];
if (x > 0) {
cout << 0 << "\n";
return;
} else {
cout << a[2] + 1 - (a[0] + a[1]) << "\n";
return;
}
}
int main() {
long long int t = 1;
while (t--) {
solve();
}
return 0;
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, x = 0;
scanf("%d%d%d", &a, &b, &c);
if ((a + b) <= c) {
x = x + (c - (a + b)) + 1;
}
if ((b + c) <= a) {
x = x + (a - (b + c)) + 1;
}
if ((a + c) <= b) {
x = x + (b - (a + c)) + 1;
}
printf("%d", x);
return 0;
}
| ### Prompt
Create a solution in CPP for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, x = 0;
scanf("%d%d%d", &a, &b, &c);
if ((a + b) <= c) {
x = x + (c - (a + b)) + 1;
}
if ((b + c) <= a) {
x = x + (a - (b + c)) + 1;
}
if ((a + c) <= b) {
x = x + (b - (a + c)) + 1;
}
printf("%d", x);
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long a, b, c;
cin >> a >> b >> c;
long long fans = 0;
if (c >= a && c >= b) {
long long ans = c - a - b;
if (ans < 0) {
fans = 0;
} else {
fans = ans + 1;
}
} else if (b >= a && b >= c) {
long long ans = b - a - c;
if (ans < 0) {
fans = 0;
} else {
fans = ans + 1;
}
} else {
long long ans = a - b - c;
if (ans < 0) {
fans = 0;
} else {
fans = ans + 1;
}
}
cout << fans << endl;
return 0;
}
| ### Prompt
Construct a cpp code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long a, b, c;
cin >> a >> b >> c;
long long fans = 0;
if (c >= a && c >= b) {
long long ans = c - a - b;
if (ans < 0) {
fans = 0;
} else {
fans = ans + 1;
}
} else if (b >= a && b >= c) {
long long ans = b - a - c;
if (ans < 0) {
fans = 0;
} else {
fans = ans + 1;
}
} else {
long long ans = a - b - c;
if (ans < 0) {
fans = 0;
} else {
fans = ans + 1;
}
}
cout << fans << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int a, b, c;
cin >> a >> b >> c;
int inf = 0x3f3f3f3f;
int ans = inf;
for (int i = a; i <= 100; i++) {
for (int j = b; j <= 100; j++) {
for (int k = c; k <= 100; k++) {
if (i + j > k && i + k > j && j + k > i)
ans = min(ans, i - a + j - b + k - c);
}
}
}
cout << ans;
return 0;
}
| ### Prompt
In cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int a, b, c;
cin >> a >> b >> c;
int inf = 0x3f3f3f3f;
int ans = inf;
for (int i = a; i <= 100; i++) {
for (int j = b; j <= 100; j++) {
for (int k = c; k <= 100; k++) {
if (i + j > k && i + k > j && j + k > i)
ans = min(ans, i - a + j - b + k - c);
}
}
}
cout << ans;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int a[3], i;
for (i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
long long int k = a[2] - (a[1] + a[0]);
if (k < 0)
cout << 0 << endl;
else
cout << k + 1 << endl;
}
| ### Prompt
Please formulate a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int a[3], i;
for (i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
long long int k = a[2] - (a[1] + a[0]);
if (k < 0)
cout << 0 << endl;
else
cout << k + 1 << endl;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d = 0;
cin >> a >> b >> c;
if (a >= b + c) {
d = a - (b + c);
d++;
} else if (b >= a + c) {
d = b - (a + c);
d++;
} else if (c >= a + b) {
d = c - (a + b);
d++;
}
cout << d;
return 0;
}
| ### Prompt
Your challenge is to write a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d = 0;
cin >> a >> b >> c;
if (a >= b + c) {
d = a - (b + c);
d++;
} else if (b >= a + c) {
d = b - (a + c);
d++;
} else if (c >= a + b) {
d = c - (a + b);
d++;
}
cout << d;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a, b, c, ans = 0;
cin >> a >> b >> c;
if (c >= a && c >= b)
ans = max(0, c + 1 - (a + b));
else if (b >= a && b >= c)
ans = max(0, b + 1 - (a + c));
else if (a >= b && a >= c)
ans = max(0, a + 1 - (b + c));
cout << ans << endl;
return 0;
}
| ### Prompt
In CPP, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a, b, c, ans = 0;
cin >> a >> b >> c;
if (c >= a && c >= b)
ans = max(0, c + 1 - (a + b));
else if (b >= a && b >= c)
ans = max(0, b + 1 - (a + c));
else if (a >= b && a >= c)
ans = max(0, a + 1 - (b + c));
cout << ans << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e;
cin >> a >> b >> c;
d = max(c, max(a, b));
if (d == a) {
if (b + c >= d + 1) {
cout << "0" << endl;
} else {
e = (d + 1) - (b + c);
cout << e << endl;
}
} else if (d == b) {
if (a + c >= d + 1) {
cout << "0" << endl;
} else {
e = (d + 1) - (a + c);
cout << e << endl;
}
} else if (d == c) {
if (a + b >= d + 1)
cout << "0" << endl;
else {
e = (d + 1) - (a + b);
cout << e << endl;
}
}
return 0;
}
| ### Prompt
Your challenge is to write a Cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e;
cin >> a >> b >> c;
d = max(c, max(a, b));
if (d == a) {
if (b + c >= d + 1) {
cout << "0" << endl;
} else {
e = (d + 1) - (b + c);
cout << e << endl;
}
} else if (d == b) {
if (a + c >= d + 1) {
cout << "0" << endl;
} else {
e = (d + 1) - (a + c);
cout << e << endl;
}
} else if (d == c) {
if (a + b >= d + 1)
cout << "0" << endl;
else {
e = (d + 1) - (a + b);
cout << e << endl;
}
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
void rewenie(int b) {
int c = b / 7;
if (b % 7 != 0) c++;
cout << c;
}
int main() {
int a, b, c;
cin >> a >> b >> c;
int sum = 0;
if (a >= b && a >= c) {
if (a >= b + c)
cout << (a - b - c) + 1;
else
goto A;
} else if (a <= b && b >= c) {
if (b >= a + c)
cout << (b - a - c) + 1;
else
goto A;
} else if (a <= c && b <= c) {
if (c >= a + b)
cout << (c - a - b) + 1;
else
goto A;
} else {
A:
cout << "0";
}
}
| ### Prompt
Construct a Cpp code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
void rewenie(int b) {
int c = b / 7;
if (b % 7 != 0) c++;
cout << c;
}
int main() {
int a, b, c;
cin >> a >> b >> c;
int sum = 0;
if (a >= b && a >= c) {
if (a >= b + c)
cout << (a - b - c) + 1;
else
goto A;
} else if (a <= b && b >= c) {
if (b >= a + c)
cout << (b - a - c) + 1;
else
goto A;
} else if (a <= c && b <= c) {
if (c >= a + b)
cout << (c - a - b) + 1;
else
goto A;
} else {
A:
cout << "0";
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int sum = 0, maxi = 0, x;
for (int i = 0; i < 3; i++) {
cin >> x;
if (x > maxi) {
maxi = x;
}
sum += x;
}
if (sum - maxi <= maxi) {
cout << maxi - (sum - maxi) + 1;
} else {
cout << 0;
}
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int sum = 0, maxi = 0, x;
for (int i = 0; i < 3; i++) {
cin >> x;
if (x > maxi) {
maxi = x;
}
sum += x;
}
if (sum - maxi <= maxi) {
cout << maxi - (sum - maxi) + 1;
} else {
cout << 0;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
ios::sync_with_stdio(false);
while (cin >> a[0] >> a[1] >> a[2]) {
sort(a, a + 3);
int ans = max(0, a[2] - a[0] - a[1] + 1);
cout << ans << endl;
}
return 0;
}
| ### Prompt
In Cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
ios::sync_with_stdio(false);
while (cin >> a[0] >> a[1] >> a[2]) {
sort(a, a + 3);
int ans = max(0, a[2] - a[0] - a[1] + 1);
cout << ans << endl;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
bool can(int a, int b, int c) {
if (a + b > c && b + c > a && c + a > b) return true;
return false;
}
int s(int a, int b, int n) { return n - a - b; }
int main() {
int a, b, c;
cin >> a >> b >> c;
if (can(a, b, c)) {
cout << 0 << endl;
return 0;
} else {
if (c > a && c > b) {
cout << s(a, b, c + 1) << endl;
} else if (a > b && a > c) {
cout << s(b, c, a + 1) << endl;
} else {
cout << s(a, c, b + 1) << endl;
}
}
}
| ### Prompt
Please create a solution in Cpp to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
bool can(int a, int b, int c) {
if (a + b > c && b + c > a && c + a > b) return true;
return false;
}
int s(int a, int b, int n) { return n - a - b; }
int main() {
int a, b, c;
cin >> a >> b >> c;
if (can(a, b, c)) {
cout << 0 << endl;
return 0;
} else {
if (c > a && c > b) {
cout << s(a, b, c + 1) << endl;
} else if (a > b && a > c) {
cout << s(b, c, a + 1) << endl;
} else {
cout << s(a, c, b + 1) << endl;
}
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
int x = a[0] + a[1];
int y = x - a[2];
if (y > 0) {
cout << 0;
} else {
cout << abs(y) + 1;
}
return 0;
}
| ### Prompt
Please create a solution in CPP to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
cin >> a[0] >> a[1] >> a[2];
sort(a, a + 3);
int x = a[0] + a[1];
int y = x - a[2];
if (y > 0) {
cout << 0;
} else {
cout << abs(y) + 1;
}
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int n = a[2] - a[1] - a[0] + 1;
cout << (n > 0 ? n : 0);
}
| ### Prompt
Your task is to create a CPP solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[3];
for (int i = 0; i < 3; i++) cin >> a[i];
sort(a, a + 3);
int n = a[2] - a[1] - a[0] + 1;
cout << (n > 0 ? n : 0);
}
``` |
#include <bits/stdc++.h>
int main() {
int a, b, c, greatest, x;
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c) {
greatest = a;
if (b + c > a)
printf("0");
else {
x = ((a - (b + c)) + 1);
printf("%d", x);
}
} else if (b > a && b > c) {
greatest = b;
if (a + c > b)
printf("0");
else {
x = ((b - (a + c)) + 1);
printf("%d", x);
}
} else if (c > a && c > b) {
greatest = c;
if (a + b > c)
printf("0");
else {
x = ((c - (a + b)) + 1);
printf("%d", x);
}
} else if (a == b == c)
printf("0");
else if (c == 100)
printf("0");
else if (c == 99)
printf("0");
return 0;
}
| ### Prompt
Create a solution in CPP for the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
int main() {
int a, b, c, greatest, x;
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c) {
greatest = a;
if (b + c > a)
printf("0");
else {
x = ((a - (b + c)) + 1);
printf("%d", x);
}
} else if (b > a && b > c) {
greatest = b;
if (a + c > b)
printf("0");
else {
x = ((b - (a + c)) + 1);
printf("%d", x);
}
} else if (c > a && c > b) {
greatest = c;
if (a + b > c)
printf("0");
else {
x = ((c - (a + b)) + 1);
printf("%d", x);
}
} else if (a == b == c)
printf("0");
else if (c == 100)
printf("0");
else if (c == 99)
printf("0");
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a + 0, a + 3);
int res = 0;
while ((a[0] + a[1]) <= a[2]) {
a[0]++;
res++;
}
cout << res;
}
| ### Prompt
In Cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int a[3];
int main() {
cin >> a[0] >> a[1] >> a[2];
sort(a + 0, a + 3);
int res = 0;
while ((a[0] + a[1]) <= a[2]) {
a[0]++;
res++;
}
cout << res;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, f, g, h;
cin >> a >> b >> c;
d = max(a, b);
e = min(a, b);
f = max(d, c);
g = min(d, c);
h = e + g;
if (h > f)
cout << 0 << endl;
else
cout << f - h + 1 << endl;
return 0;
}
| ### Prompt
Please formulate a cpp solution to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, f, g, h;
cin >> a >> b >> c;
d = max(a, b);
e = min(a, b);
f = max(d, c);
g = min(d, c);
h = e + g;
if (h > f)
cout << 0 << endl;
else
cout << f - h + 1 << endl;
return 0;
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, a1, b1, c1;
cin >> a >> b >> c;
a1 = (a + c - b);
b1 = (a + b - c);
c1 = (b + c - a);
if (a1 > 0 && b1 > 0 && c1 > 0) {
cout << 0;
return 0;
} else if (a1 < b1 && a1 < c1) {
cout << abs(a1) + 1;
return 0;
}
if (c1 < b1 && c1 < a1) {
cout << abs(c1) + 1;
return 0;
}
if (b1 < a1 && b1 < c1) {
cout << abs(b1) + 1;
return 0;
}
}
| ### Prompt
In cpp, your task is to solve the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, a1, b1, c1;
cin >> a >> b >> c;
a1 = (a + c - b);
b1 = (a + b - c);
c1 = (b + c - a);
if (a1 > 0 && b1 > 0 && c1 > 0) {
cout << 0;
return 0;
} else if (a1 < b1 && a1 < c1) {
cout << abs(a1) + 1;
return 0;
}
if (c1 < b1 && c1 < a1) {
cout << abs(c1) + 1;
return 0;
}
if (b1 < a1 && b1 < c1) {
cout << abs(b1) + 1;
return 0;
}
}
``` |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
x = 0;
int f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - 48;
ch = getchar();
}
x *= f;
}
int a, b, c, d;
int main() {
read(a), read(b), read(c);
d = max(a, max(b, c));
d = -a - b - c + 2 * d;
printf("%d\n", max(0, d + 1));
return ~~(0 ^ 0 ^ 0);
}
| ### Prompt
Please create a solution in cpp to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
x = 0;
int f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - 48;
ch = getchar();
}
x *= f;
}
int a, b, c, d;
int main() {
read(a), read(b), read(c);
d = max(a, max(b, c));
d = -a - b - c + 2 * d;
printf("%d\n", max(0, d + 1));
return ~~(0 ^ 0 ^ 0);
}
``` |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if (a > b) swap(a, b);
if (b > c) swap(b, c);
int ans = c - (a + b);
printf("%d", ans >= 0 ? ans + 1 : 0);
}
| ### Prompt
Construct a Cpp code solution to the problem outlined:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if (a > b) swap(a, b);
if (b > c) swap(b, c);
int ans = c - (a + b);
printf("%d", ans >= 0 ? ans + 1 : 0);
}
``` |
#include <bits/stdc++.h>
using namespace std;
int func(int a, int b, int c) {
if (a > b + c && b > a + c && c > a + b) {
return (1);
}
return (0);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a, b, c;
cin >> a >> b >> c;
int x = min(a, min(b, c));
int z = max(a, max(b, c));
int y = a + b + c - x - z;
long long int ans;
if (z < x + y) {
ans = 0;
} else {
ans = z - x - y + 1;
}
cout << ans;
return (0);
}
| ### Prompt
Please create a solution in CPP to the following problem:
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.
Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
Note
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 2 centimeter stick by one and after that form a triangle with sides 3, 3 and 5 centimeters.
In the third example, Masha can take 33 minutes to increase one of the 10 centimeters sticks by 33 centimeters, and after that take 48 minutes to increase another 10 centimeters stick by 48 centimeters. This way she can form a triangle with lengths 43, 58 and 100 centimeters in 81 minutes. One can show that it is impossible to get a valid triangle faster.
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
int func(int a, int b, int c) {
if (a > b + c && b > a + c && c > a + b) {
return (1);
}
return (0);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a, b, c;
cin >> a >> b >> c;
int x = min(a, min(b, c));
int z = max(a, max(b, c));
int y = a + b + c - x - z;
long long int ans;
if (z < x + y) {
ans = 0;
} else {
ans = z - x - y + 1;
}
cout << ans;
return (0);
}
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.