Skip to content

Commit fd43652

Browse files
committed
added my solution for problem Day01
1 parent 98005d0 commit fd43652

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
11+
int diff = abs(a - b);
12+
int N = 2 * diff;
13+
if (diff == 0 || max({a, b, c}) > N) {
14+
cout << -1 << '\n';
15+
continue;
16+
}
17+
18+
if (c > N / 2) {
19+
cout << c - N / 2 << '\n';
20+
} else {
21+
cout << c + N / 2 << '\n';
22+
}
23+
}
24+
}
16.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)