Skip to content

Commit efda9d3

Browse files
committed
Issue 2 completed
1 parent 64e3d68 commit efda9d3

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
void solve(){
5+
int x, y, pos;
6+
cin >> x >> y >> pos;
7+
8+
int cs = 2 * abs(x - y);
9+
10+
int opp = pos + cs / 2;
11+
12+
if (pos > cs || y > cs || x > cs) {
13+
cout << -1 << endl;
14+
return;
15+
}
16+
17+
if (opp > cs)
18+
opp -= cs;
19+
20+
cout << opp << endl;
21+
}
22+
23+
int main(){
24+
int t;
25+
cin >> t;
26+
while (t--) solve();
27+
}

0 commit comments

Comments
 (0)