Write a program to keep a collection of words. There are two instructions:
“AFEGEIX”
adds the word
to the collection, and prints nothing.
“SEGUENT” deletes the longest word of the
collection, and prints it. In the event of a tie, it deletes the word
that was added first.
Input consists of a sequence of instructions. The given words are made up of only lowercase letters, and can be repeated.
For every “SEGUENT” instruction, print a line with the
required word according to the rules given above. You can assume that
there will always be at least one word.
“Afegeix” is Catalan for “add”, and “següent” is Catalan for “next”.
Author: Unknown
Translator: Salvador Roura
Generation: 2026-01-25T11:57:36.188Z
© Jutge.org, 2006–2026.
https://jutge.org