Absolutely Flat
Time limit2sMemory limit1024 MB
Given four leg lengths and one pad length, decide whether attaching the pad to at most one leg can make all four legs equal.
- Level
Easy1 of 10
- Topics
- Implementation, Brute force
- Solved
- No attempts yet
Problem
Alice owns a table with four legs, and she wants it to be flat. The table is flat if all four legs have equal lengths.
Alice measured the current leg lengths and got , and . She also has a pad of length . She can attach the pad to one of the legs, which increases that leg's length by . She can also skip the pad and leave all legs unchanged. She has only one pad, so she cannot apply it twice to the same leg or to two different legs.
Determine whether Alice can make the table flat.
Input
The input contains five positive integers , and , each on a separate line ().
Output
Print if Alice can make the table flat, and otherwise.
Hints
In the first example, the table is already flat, so no pad is needed.
In the second example, Alice can attach the pad to the third leg to make the table flat.
In the third and fourth examples, Alice cannot make the table flat.