Skip to content

Commit 3451a75

Browse files
committed
Solution of problem 1 day 1
1 parent 66e1c4d commit 3451a75

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main(int argc, char const *argv[])
5+
{
6+
int t;
7+
cin >> t;
8+
while (t--)
9+
{
10+
long long int a, b, c;
11+
cin >> a >> b >> c;
12+
if ((c <= abs(b - a) * 2) && (abs(b - a) >= min(a, b)))
13+
{
14+
if (c + abs(b - a) <= abs(b - a) * 2)
15+
{
16+
cout << c + abs(b - a) << endl;
17+
}
18+
else
19+
{
20+
cout << c - abs(b - a) << endl;
21+
}
22+
}
23+
else
24+
{
25+
cout << -1 << endl;
26+
}
27+
}
28+
29+
return 0;
30+
}

0 commit comments

Comments
 (0)