#K78472. Identify Bird Species Sightings

    ID: 35094 Type: Default 1000ms 256MiB

Identify Bird Species Sightings

Identify Bird Species Sightings

You are given an integer \( n \) indicating the number of days and a sequence of \( n \) integers representing the bird species sighted on each day. Your task is to determine:

  • The total number of distinct bird species observed.
  • The first day each species was spotted.

For example, for \( n = 7 \) and sightings \( [4, 5, 4, 2, 5, 2, 4] \), the distinct species count is 3 and the first sightings are: species 4 on day 1, species 5 on day 2, and species 2 on day 4.

Note: Use stdin to read input and stdout to print the result.

inputFormat

The input is read from stdin and consists of:

  1. The first line contains an integer \( n \), the number of days.
  2. The second line contains \( n \) space-separated integers representing the bird sightings.

outputFormat

The output should be written to stdout as follows:

  1. The first line contains a single integer representing the number of distinct bird species.
  2. Each of the following lines contains two integers separated by a space: the bird species and the day of its first sighting, in the order of their first appearance.
## sample
7
4 5 4 2 5 2 4
3

4 1 5 2 2 4

</p>