Skip to content

Commit dc3467a

Browse files
authored
Merge pull request #210 from Apoorv012/d1_q1
Apoorv012: Day 1, Ques 1
2 parents e0b9bd8 + 5ccaf53 commit dc3467a

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

  • Problems/Mathematics/Day-01/sol/Apoorv012
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
using ll = long long;
5+
const ll MOD = 998244353;
6+
7+
void solve() {
8+
int a, b, c;
9+
cin >> a >> b >> c;
10+
11+
int diff = abs(a-b);
12+
if (a > 2*diff || b > 2*diff || c > 2*diff) {
13+
cout << -1 << endl;
14+
return;
15+
}
16+
17+
int ans = c + diff;
18+
if (ans > 2*diff) {
19+
ans -= 2*diff;
20+
}
21+
22+
cout << ans << endl;
23+
24+
}
25+
26+
int main() {
27+
ios::sync_with_stdio(false);
28+
cin.tie(nullptr);
29+
30+
int t = 1;
31+
cin >> t;
32+
33+
while (t--) {
34+
solve();
35+
}
36+
37+
return 0;
38+
}

0 commit comments

Comments
 (0)