Skip to content

Commit f738958

Browse files
Merge pull request #163 from mayankrai2404/solution-branch
Added solution for Question 01
2 parents 0c2a7a2 + f210472 commit f738958

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define umpp(i, j) unordered_map<i, j, custom_hash>
5+
#define mpp(i, j) map<i, j>
6+
#define int long long
7+
#define ll long long
8+
#define vi vector<int>
9+
#define pii pair<int, int>
10+
#define vpii vector<pair<int,int>>
11+
#define pb push_back
12+
#define pob pop_back
13+
#define sz(x) ((int)(x).size())
14+
#define all(v) v.begin(), v.end()
15+
#define F first
16+
#define S second
17+
#define sortall(x) sort(all(x))
18+
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
19+
#define forx(x, n) for (int x = 0; x < (n); x++)
20+
#define PI 3.1415926535897932384626
21+
const int mod = 1e9 + 7;
22+
23+
void solve() {
24+
int a,b,c; cin >> a>>b>>c;
25+
int diff = abs(a - b);
26+
int t = 2 * diff;
27+
if(a>t || b>t||c>t){
28+
cout << -1 << endl;
29+
}
30+
else{
31+
int a1 = c - diff;
32+
int a2 = c + diff;
33+
if(a1>=1 && a1<=t){
34+
cout << a1 << endl;
35+
return;
36+
}
37+
cout << a2 << endl;
38+
}
39+
}
40+
41+
signed main() {
42+
ios_base::sync_with_stdio(0);
43+
cin.tie(0);
44+
cout.tie(0);
45+
srand(chrono::high_resolution_clock::now().time_since_epoch().count());
46+
int t = 1;
47+
cin >> t;
48+
while (t--) solve();
49+
return 0;
50+
}

0 commit comments

Comments
 (0)