PROBLEM STATEMENT You want to type a document containing only spaces and new lines. Let SP and NL denote a space character and a new line character, respectively. You are given a vector lines describing the desired document. The elements of lines represent the number of SP characters in each line, in order. Each line must end with a NL character. In other words, the document should look like this: lines[0] SP characters, followed by a NL, followed by lines[1] SP characters, followed by a NL, ..., lines[N-1] SP characters, followed by a NL (where N is the number of elements in lines). The editor has a cursor, which can be positioned between two adjacent characters or at the beginning or end of the document. You can move this cursor freely. The editor has three special keys: SPACE: inserts a SP at the position of the cursor. DELETE: deletes a SP character immediately to the right of the cursor. This key cannot be used if the character to the right of the cursor is a NL. RETURN: inserts a NL followed by some number of SP characters. This key can only be used when the character immediately to the right of the cursor is a NL. The number of SP characters that get inserted is equal to the number of SP characters in the line where the cursor is. For example, if the document is "SP NL SP SP NL SP SP SP NL", and the cursor is immediately to the left of the second NL, it will become "SP NL SP SP NL SP SP NL SP SP SP NL" after pressing RETURN. The document initially contains nothing but a single NL character. Return the minimum number of times you must press SPACE, DELETE or RETURN to complete the document. DEFINITION Class:WhiteSpaceEditing Method:getMinimum Parameters:vector Returns:int Method signature:int getMinimum(vector lines) CONSTRAINTS -lines will contain between 1 and 50 elements, inclusive. -Each element of lines will be between 0 and 1,000,000, inclusive. EXAMPLES 0) { 3, 2, 3 } Returns: 6 You can edit the document as follows: NL SP NL SP SP NL SP SP SP NL SP SP SP NL SP SP SP NL SP SP SP NL SP SP SP NL SP SP SP NL SP SP SP NL SP SP NL SP SP SP NL 1) { 0 } Returns: 0 You have to do nothing. 2) { 1, 2, 4 } Returns: 6 3) { 250, 105, 155, 205, 350 } Returns: 499 This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.