Skip to content

Commit ca40ec2

Browse files
authored
Merge pull request #72 from avaneeshk2307-wq/patch-3
Create solution001.py
2 parents 3cec148 + f130657 commit ca40ec2

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main() {
5+
int t;
6+
cin >> t;
7+
while (t--) {
8+
int a, b, c;
9+
cin >> a >> b >> c;
10+
11+
int diff = abs(a - b);
12+
int n = 2 * diff;
13+
if (diff == 0 || a > n || b > n || c > n) {
14+
cout << -1 << '\n';
15+
continue;
16+
}
17+
int half = n / 2;
18+
int d;
19+
if (c + half <= n)
20+
d = c + half;
21+
else
22+
d = c - half;
23+
cout << d << '\n';
24+
}
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)