#C2687. Longest Word Problem

    ID: 46030 Type: Default 1000ms 256MiB

Longest Word Problem

Longest Word Problem

You are given a list of words. Your task is to find and output the longest word. If there are multiple words with the same maximum length, output the one that appears first in the input.

Note: When there are no words (i.e. an empty list), output an empty string.

The problem can be formalized as follows:

Given a list \(W = [w_1, w_2, \dots, w_n]\), find the word \(w_k\) such that \(\ell(w_k) = \max\{\ell(w_1), \ell(w_2), \dots, \ell(w_n)\}\) and if there is more than one such word, choose the one with the smallest index.

inputFormat

The input is given via standard input (stdin) and consists of multiple lines. The first line contains an integer n which represents the number of words. The following n lines each contain a single word. If n is 0, then no words follow.

outputFormat

Output the longest word to standard output (stdout). If there are multiple words with the same maximal length, output the one that appears first. If the input list is empty, output an empty string.

## sample
3
apple
banana
cherry
banana