cswork / OAOpen practice workspace

MicrosoftOA #55

Prepare Notification

Estimated EasyJudge-ready

Topics (AI-labelled)Strings

A message consists of English words separated by single spaces. If it exceeds K characters, delete some whole words from the end and append " ..." (a space followed by three ASCII periods); if no word can be kept, show only "...". Find the longest valid notification. The source's examples were inconsistent about the space before the ellipsis, so this site corrected them by the single-space rule stated in the statement.

This site uses a standard input/output protocol.

Input

The first line contains K (3..500), and the second line contains message (1..500 characters), consisting only of English letters and spaces, with no leading, trailing, or consecutive spaces.

Output

Output the full notification followed by a terminating newline.

Example 1

Input:

15
And now here is my secret

Output:

And now ...

Example 2

Input:

4
super dog

Output:

...

Example 3

Input:

20
how are you

Output:

how are you

Example notes

Example 1: keep And now, then append a space and three periods, outputting "And now ..."; also keeping here would make the length 16. Example 2: any word plus the suffix exceeds 4, so only "..." is possible. Example 3: the whole sentence has length 11, which does not exceed 20, so it is returned unchanged.

Editorial

Loading solution…