-
Notifications
You must be signed in to change notification settings - Fork 0
/
Who's Opposite.cpp
51 lines (37 loc) · 989 Bytes
/
Who's Opposite.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Problem: https://codeforces.com/problemset/problem/1560/B
// Solved on January 18th 2023
#include <iostream>
using namespace std;
int main()
{
int caseAmount, circleAmount, a, b, c, d, r;
cin >> caseAmount;
int outputValues[100000];
for (int i = 0; i < caseAmount; i++) {
cin >> a >> b >> c;
if (a > b) {
r = a - b;
}
else {
r = b - a;
}
circleAmount = r * 2;
if (a > circleAmount || b > circleAmount || c > circleAmount) {
outputValues[i] = -1;
}
else {
if (c + r <= circleAmount) {
outputValues[i] = c + r;
}
else if (c-r<=circleAmount&&c-r>0){
outputValues[i] = c - r;
}
else {
outputValues[i] = -1;
}
}
}
for (int j = 0; j < caseAmount; j++) {
cout << outputValues[j] << "\n";
}
}