Partition Equal Subset Sum
Girvan Haulage sends two vans out together and wants the load split so both carry the same weight. Every crate must go on one van or the other — nothing is left behind at the depot and no crate is broken up. Sometimes no such split exists and the depot needs to know so it can call a third van instead.
Task: Print whether the crates can be split between two vans carrying equal weight.
Input
A single line holding between 1 and 200 positive integers separated by single spaces — the crate weights. Weights may repeat, and the total never exceeds 20000.
Output
One line holding exactly Yes or No, with that capitalisation. Yes means the crates can be dealt into two groups of equal total weight. Every crate must go into exactly one of the two groups.
Example:
Input:
1 5 11 5
Output:
Yes
({1, 5, 5} and {11} both sum to 11)
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in