Skip to content

Commit 466ac8e

Browse files
committed
Solution 1
1 parent a9b55f2 commit 466ac8e

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//#include <bits/stdc++.h>
2+
#include <iostream>
3+
#include <vector>
4+
#include <string>
5+
#include <algorithm>
6+
#include <map>
7+
#include <set>
8+
#include <unordered_map>
9+
#include <queue>
10+
#include <stack>
11+
#include <cmath>
12+
#include <climits>
13+
#define int long long
14+
#define fo(n) for (int i = 0; i < n; i++)
15+
#define fo1(ii, n) for(int i=ii; i<n; i++)
16+
#define all(x) x.begin(), x.end()
17+
#define rall(x) x.rbegin(), x.rend()
18+
#define pb push_back
19+
#define fi first
20+
#define se second
21+
#define vec(a) vector<int> a
22+
#define vecn(a,n) vector<int> a(n)
23+
#define py cout<<"YES"<<endl
24+
#define pn cout<<"NO"<<endl
25+
const int MOD = 1e9 + 7;
26+
const int INF = 1e18;
27+
using namespace std;
28+
29+
void solve(){
30+
int a,b,c;
31+
cin>>a>>b>>c;
32+
//a->b
33+
//c->?
34+
int total=abs(a-b)*2;
35+
int half=total/2;
36+
if(max({a,b,c})>total){
37+
cout<<-1<<endl;
38+
return;
39+
}
40+
else if(c<=total){
41+
if(c>half){
42+
cout<<c-half<<endl;
43+
}
44+
else cout<<c+half<<endl;
45+
}
46+
}
47+
48+
signed main() {
49+
ios_base::sync_with_stdio(false);
50+
cin.tie(0);
51+
int t;
52+
cin >> t;
53+
while(t--)
54+
solve();
55+
return 0;
56+
}

0 commit comments

Comments
 (0)