Does it mean, that I should minimize the number of lines that can't be printed with length n, and then minimize the number of hyphenations?You should do as few hyphenations as possible. However, if it is impossible to justify a line of the text, output it left-justified.
If yes, why the output for last sample test case is not:
Code: Select all
This
is a-
n ex-
ample
of a
para-
graph
whic-
h is
pret-
typr-
inte-
d on
a r-
ow w-
ith a
leng-
th of
five.