Skip to content

Commit ab228ea

Browse files
authored
Merge pull request #108 from arnavsingh010/Arnav
2 parents 12f6911 + c39ad8e commit ab228ea

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+
//adding submission link as suggested earlier
2+
//https://codeforces.com/problemset/submission/1560/355167404
3+
4+
#include <bits/stdc++.h>
5+
using namespace std;
6+
7+
int main() {
8+
int t;
9+
cin >> t;
10+
while(t--) {
11+
int a,b,c;
12+
cin>>a>>b>>c;
13+
if((abs(b-a))*2<max(a,max(b,c))){
14+
cout << -1 <<'\n';
15+
continue;
16+
}
17+
if(c+(abs(b-a))>(abs(b-a)*2)){
18+
cout<<(c+(abs(b-a)))%(abs(b-a)*2)<<'\n';
19+
}
20+
else{
21+
cout<<c+(abs(b-a))<<'\n';
22+
}
23+
}
24+
25+
return 0;
26+
}

0 commit comments

Comments
 (0)