The firefighters of a distant country want to protect the grannies inside schools. All the schools are in a row on a street, numbered in order from 1 to . At each school there are grannies. The firefighters can form groups, and each group can only go to a single school. If a group goes to school , it protects all the grannies there. In addition, it also indirectly protects half the grannies in school , assuming that it exists and that it is not already fully protected by another group; and similarly with school .
What is the maximum number of grannies that can be protected?
Input consists of several cases, each one with and , followed by the ’s. You can assume , and that all the ’s are even natural numbers between 2 and .
For every case, print how many grannies can be protected.
The expected solution for this problem is a reasonable backtracking.
Author: Unknown
Translator: Salvador Roura
Generation: 2026-01-25T10:20:02.552Z
© Jutge.org, 2006–2026.
https://jutge.org