Skip to content

Commit 93d3128

Browse files
Create solution.cpp
1 parent 6ab8b23 commit 93d3128

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//https://codeforces.com/contest/1560/problem/C
2+
// TC : O(1) SC: O(1)
3+
#include <bits/stdc++.h>
4+
using namespace std;
5+
6+
int main() {
7+
int t;
8+
cin>>t;
9+
while(t--){
10+
int a,b,c;
11+
cin>>a>>b>>c;
12+
int k=abs(a-b);
13+
if(a>2*k || b>2*k || c>2*k){
14+
cout<<-1<<endl;
15+
}
16+
else{
17+
if((c-k)>0){
18+
cout<<c-k<<endl;
19+
}
20+
else{
21+
cout<<c+k<<endl;
22+
}
23+
}
24+
}
25+
26+
}

0 commit comments

Comments
 (0)