Skip to content

Commit dfb044e

Browse files
Create Make a Triangle Explanation.txt
1 parent c94fb3a commit dfb044e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}

0 commit comments

Comments
 (0)