Three Sticks
InterviewTime limit2sMemory limit512 MB
Given three stick lengths, shorten them to positive integers so they form a non-degenerate triangle with the largest possible perimeter.
- Level
Easy3 of 10
- Topics
- Greedy, Math, Implementation, Sorting
- Solved
- No attempts yet
Problem
Yeongseon has three sticks of lengths , , and , and she can shorten each stick to any length she likes.
She wants to build a triangle out of the three sticks so that all of the following hold.
- The length of each stick is a positive integer.
- The three sticks form a triangle of positive area.
- The perimeter of the triangle is as large as possible.
Given , , and , write a program that finds the largest perimeter she can build.
Input
The first line contains three integers , , . ()
Output
Print the largest perimeter of a triangle that can be built.