#K36997. Even Lock Distribution
Even Lock Distribution
Even Lock Distribution
You are given four locks, each with a certain number of pins. The task is to determine whether it is possible to split these four locks into two groups such that the total number of pins in each group is equal.
More formally, let \(p_1, p_2, p_3, p_4\) represent the number of pins in each lock. Define the total number of pins as \(S = p_1 + p_2 + p_3 + p_4\). The problem asks whether there exist two distinct locks (or a combination of locks) whose sum equals \(\frac{S}{2}\). Note that if \(S\) is odd then the split is impossible.
In this problem, you will read four integers from standard input and output YES
if an equal distribution is possible, and NO
otherwise.
inputFormat
The input consists of a single line containing four space-separated integers \(p_1, p_2, p_3, p_4\) representing the number of pins on each of the four locks.
outputFormat
Output a single line with the word YES
if it is possible to split the locks into two groups with equal total pins, otherwise output NO
.
3 9 5 7
YES