Long words

Write a program that checks whether a given text reaches a goal number
of words of at least a given goal length. The program reads first the
goal number n and the goal length m; they are integers coming in the
first line. Then finds out whether the text that follows them contains
at least n different words of length at least m. If so, it outputs the n
words, sorted according to the standard string ordering, each in a line.
Otherwise, it prints Goal not attained.

Input

Input consists of two numbers n and m, being respectively the goal
number and the goal length, followed by a sequence of words. Numbers n
and m are integers, n is greater than zero and m is non negative.

Output

In case the goal is achieved, the output consists of n lines with the n
first different words in the input text whose length is at least m.
Words are shown according to the standard string order, one by line.
When goal is not reached, a line with the message Goal not attained

Problem information

Author: ProAl

Generation: 2026-01-25T17:16:23.966Z

© Jutge.org, 2006–2026.
https://jutge.org
