Editorial for Wesley's Anger Contest 3 Problem 2 - Eat, Sleep, Code, Repeat
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
For subtask 1, one can loop through all possible integer value of hours from to for all three variables. All that's left is to check whether or not the sum of the three variables is equal to and whether or not its product is the greatest.
Time Complexity:
Subtask 2
For subtask 2, one can loop through all pairs of hours from to for two variables, then solve for the third one algebraically.
Time Complexity:
Subtask 3
For subtask 3, one can loop through to for the first number, then solve a simpler version of this problem:
Given an integer , find two nonnegative integers and such that and the product of and is maximized.
This value is maximized when the absolute difference between and is minimized. Try expanding and compare it to !
Careful steps must be taken to ensure that the three variables must sum up to .
Time Complexity:
Subtask 4
For the full solution, we can apply the same idea and extend it to variables. To solve for three variables, the maximum absolute difference should be minimized while ensuring that they still sum up to .
Time Complexity:
Comments