eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Ragged Right

Ragged Right

Word wrapping is the task of deciding how to break a paragraph of text into lines. For aesthetic reasons, we’d like all the lines except the last one to be about the same length. For example, we would say the text on the left looks less ragged than the text on the right: Your job is to compute a raggedness value for an arbitrary paragraph of text. We’ll measure raggedness in a way similar to the \textbf{T_EX} typesetting system. Let n be the length, measured in characters, of the longest line of the paragraph. If some other line contains only \textbf{m} characters, then we’ll charge a penalty score of \textbf{(n−m)^2} for that line. The raggedness will be the sum of the penalty scores for every line except the last one. \InputFile Input consists of a single paragraph of text containing at most \textbf{100} lines. Each line of the paragraph contains a sequence of between \textbf{1} and \textbf{80} characters (letters, punctuation characters, decimal digits and spaces). No line starts or ends with spaces. The paragraph ends at end of file. \OutputFile Print out a single integer, the raggedness score for paragraph.
Лимит времени 1 секунда
Лимит использования памяти 256 MiB
Входные данные #1
some blocks
of text line up
well on the right,
but
some don't.
Выходные данные #1
283
Источник 2012 ACM-ICPC North American Qualification Contest