CPUlm Winter Contest 2022 |
---|
Finished |
Hermione was really proud of her one million word text she wrote for her assignment. She was, until she realized that the text must be handed in on a single piece of paper with limited dimensions. Obviously, she could have just shortened her text, but Hermione decided to go another route. She decided to just copy her text to a new piece of paper, writing a little bit smaller... To make this easier, she decided to first change the line breaks in her text such that the sum of the height and width of the piece of paper is minimized. Given Hermione's text with $$$n$$$ words and assuming that each character takes up one unit height and one unit width, what is the minimal height plus width that can be achieved by inserting line breaks? Note that two words which are on the same line need to be separated by a single space.
The input consists of:
Output a single integer, the sum of the height and width of the smallest piece of paper the text could fit on.
4 i am lord voldemort
11
10 i solemnly swear that i am up to no good
14
Name |
---|