B. 【例61.2】 最近的一对

    Type: Default 1000ms 64MiB

【例61.2】 最近的一对

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

Given an array aa containing nn elements, find the pair of indices ii and jj in aa that are closest to each other, satisfying i<ji < j and a[i]=a[j]a[i] = a[j]. If multiple pairs exist, output the value of a[i]a[i] corresponding to the smallest ii. For example, in the array of 1010 numbers 19,13,11,19,11,5,6,3,4,319, 13, 11, 19, 11, 5, 6, 3, 4, 3, the numbers that satisfy a[i]=a[j]a[i] = a[j] include 19,11,319, 11, 3. Among these, the pairs 1111 and 33 are closer in distance, and in the case of equal distances, 1111 has a smaller index. If no identical numbers exist, output "No".

Input Format

The first line contains a single integer nn representing the length of the array (2n1000002 \le n \le 100000).
The next nn lines each contain a single integer, representing the elements of the array (1a[i]1091 \le a[i] \le 10^9).

Output Format

Output the value of a[i]a[i] corresponding to the smallest ii that meets the conditions.

Sample

10
19
13
11
19
11
5
6
3
4
3
11

20250915D班作业(1)

Not Claimed
Status
Done
Problem
4
Open Since
2025-9-14 0:00
Deadline
2025-9-22 23:59
Extension
24 hour(s)