시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB135938671.667%

문제

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:

This is a                         This
paragraph                         is a paragraph
of text.                          of text.

Your job is to compute a raggedness value for an arbitrary paragraph of text. We’ll measure raggedness in a way similar to the TEX typesetting system. Let n be the length, measured in characters, of the longest line of the paragraph. If some other line contains only m characters, then we’ll charge a penalty score of (n − m)2 for that line. The raggedness will be the sum of the penalty scores for every line except the last one.

입력

Input consists of a single paragraph of text containing at most 100 lines. Each line of the paragraph contains a sequence of between 1 and 80 characters (letters, punctuation characters, decimal digits and spaces). No line starts or ends with spaces. The paragraph ends at end of file.

출력

Print out a single integer, the raggedness score for paragraph.

예제 입력 1

some blocks
of text line up
well on the right,
but
some don't.

예제 출력 1

283

예제 입력 2

this line is short
this one is a bit longer
and this is the longest of all.

예제 출력 2

218

출처

ICPC > Regionals > North America > North America Qualification Contest > ACM-ICPC North America Qualifier 2012 K번

  • 문제를 만든 사람: David Sturgill