#C7096. Most Sighted Animal in a Time Period

    ID: 50929 Type: Default 1000ms 256MiB

Most Sighted Animal in a Time Period

Most Sighted Animal in a Time Period

You are given a series of animal sighting logs. Each log contains a timestamp, a unique animal ID, and a location. Given a specific time window defined by a start time and an end time (both inclusive), your task is to determine which animal was sighted the most number of times within this period. In the case of a tie, the animal ID that is lexicographically smallest (i.e., appears first in alphabetical order) should be returned.

Note: All timestamps follow the format \(YYYY\text{-}MM\text{-}DD\ HH:MM:SS\).

inputFormat

The input is read from stdin and is structured as follows:

  1. An integer \(n\) representing the number of sighting logs.
  2. Then \(n\) lines follow, each containing a log entry in the format: timestamp;animal_id;location, where timestamp is in the format \(YYYY-MM-DD HH:MM:SS\).
  3. The next line is a string representing the start time in the same timestamp format.
  4. The last line is a string representing the end time in the same timestamp format.

outputFormat

Output to stdout a single line containing the unique ID of the most sighted animal in the given period. If there is a tie, output the lexicographically smallest animal ID.

## sample
1
2023-01-01 12:00:00;ELEPHANT;Zone A
2023-01-01 00:00:00
2023-01-01 23:59:59
ELEPHANT