Editorial for Another Contest 5 Problem 1 - Goat Fence
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.
With the bounds as low as they are, several different solutions were possible. One approach is to brute force over all pairs of side lengths and where and list out the rectangle with the maximum perimeter - with , this solution comfortably runs in time.
It follows fairly directly from the problem statement that the maximum perimeter is at least - a rectangle with dimensions clearly attains this perimeter. We actually cannot do better than this. Therefore, it suffices to read in and print .
Comments