Skip to content

Commit 60f7795

Browse files
authored
Create solution1.cpp
1 parent edabfd2 commit 60f7795

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)