File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Contests/Moscow Team Olympiad 2018/Explanation Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ Let the sides be a < b < c
2
+
3
+ The triangle is valid if c < a + b
4
+
5
+ Now, if c < a + b,
6
+
7
+ Then since a < c and b < c the other two sides satisfy the inequality.
8
+
9
+ -------------------------------------
10
+
11
+ We just change the smallest side, the other two sides will obey the inequality.
12
+
13
+ -----------------------
14
+
15
+ #include <iostream>
16
+ #include <vector>
17
+ #include <algorithm>
18
+
19
+ using namespace std;
20
+
21
+ int main()
22
+ {
23
+ vector <int> A(3);
24
+ cin >> A[0] >> A[1] >> A[2];
25
+
26
+ sort(A.begin(), A.end());
27
+
28
+ int minutes = 0;
29
+
30
+ if(A[0] + A[1] <= A[2])
31
+ {
32
+ minutes += (A[2] + 1 - A[1] - A[0]);
33
+ }
34
+
35
+ cout << minutes;
36
+ return 0;
37
+ }
You can’t perform that action at this time.
0 commit comments