Editorial for WC '17 Contest 2 J3 - Escaping the Mines
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Let's start by looping over the values and determining which members of the Fellowship are able to clear the chasm by themselves (all members such that ). Let be the number of members who can do so, and let be the number of members who cannot. Each member of the former group can help out at most one member of the latter group, meaning that extra members can get carried across in addition to the members who can jump across regardless. This gives us an answer of .
Comments