Skip to content

Commit 50eee96

Browse files
committed
solved q1
1 parent 7f7e501 commit 50eee96

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main() {
5+
int t;
6+
cin >> t;
7+
while(t--) {
8+
int a,b,c;
9+
cin>>a>>b>>c;
10+
if((abs(b-a))*2<max(a,max(b,c))){
11+
cout << -1 <<'\n';
12+
continue;
13+
}
14+
if(c+(abs(b-a))>(abs(b-a)*2)){
15+
cout<<(c+(abs(b-a)))%(abs(b-a)*2)<<'\n';
16+
}
17+
else{
18+
cout<<c+(abs(b-a))<<'\n';
19+
}
20+
}
21+
22+
return 0;
23+
}

0 commit comments

Comments
 (0)