#C3040. Find the Longest Word

    ID: 46424 Type: Default 1000ms 256MiB

Find the Longest Word

Find the Longest Word

You are given a list of words and your task is to find the first word that has the maximum length among them. In case there are multiple words with the same maximum length, you should output the one that appears first in the list.

The problem requires reading the input from the standard input and displaying the result to the standard output.

Mathematically, if the list of words is represented as \(w_1, w_2, \dots, w_n\), then find the first word \(w_k\) such that \(|w_k| \geq |w_i|\) for all \(1 \leq i \leq n\), where \(|w|\) denotes the length of the word.

inputFormat

The input is provided via standard input (stdin) and contains two lines:

  • The first line contains a single integer \(n\) (where \(1 \leq n \leq 10^5\)), representing the number of words.
  • The second line contains \(n\) space-separated words. Each word consists of alphanumeric characters.

outputFormat

Output to standard output (stdout) a single line containing the first word with the maximum length.

If multiple words share the same maximum length, output the first one encountered in the list.

## sample
1
apple
apple