Skip to content

Commit cf201f7

Browse files
committed
Create Solution1.cpp
1 parent 00502aa commit cf201f7

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)