Starving velociraptor

The 10th grade class of a certain Catalan high school is going on a
field trip. Just when the bus reaches the destination and the doors
open, a starving velociraptor gets in looking like it just found its
favorite candy. Alas! This things happen.

However, velociraptors are very intelligent and organized animals. It
knows it won’t be able to eat everyone but it’s so hungry, so it decides
to eat as many people as possible as long as all of them have the exact
same weight. Naturally, the superior intelligence of velociraptors
allows them to compute each person’s weight with just a glimpse.

Input

Input contains several cases. Each case consists of a line with an
integer 1 ≤ n ≤ 10⁶ indicating the number of people in the bus, followed
by n numbers representing the weight of each person in the order they
are seated. Every weight is between 30 and 150.

Output

Print a line for each case with the maximum number of people with the
same weight, followed by the weight of these people. If case of a tie,
choose the greatest weight.

Problem information

Author: Unknown
Translator: Alex Alvarez

Generation: 2026-01-25T17:25:08.426Z

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