CF886B.Vlad and Cafes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vlad likes to eat in cafes very much. During his life, he has visited cafes nn times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.

First of all, Vlad assigned individual indices to all cafes. Then, he wrote down indices of cafes he visited in a row, in order of visiting them. Now, Vlad wants to find such a cafe that his last visit to that cafe was before his last visits to every other cafe. In other words, he wants to find such a cafe that he hasn't been there for as long as possible. Help Vlad to find that cafe.

输入格式

In first line there is one integer nn ( 1<=n<=21051<=n<=2·10^{5} ) — number of cafes indices written by Vlad.

In second line, nn numbers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 0<=ai<=21050<=a_{i}<=2·10^{5} ) are written — indices of cafes in order of being visited by Vlad. Vlad could visit some cafes more than once. Note that in numeration, some indices could be omitted.

输出格式

Print one integer — index of the cafe that Vlad hasn't visited for as long as possible.

输入输出样例

  • 输入#1

    5
    1 3 2 1 2
    

    输出#1

    3
    
  • 输入#2

    6
    2 1 2 2 4 1
    

    输出#2

    2
    

说明/提示

In first test, there are three cafes, and the last visits to cafes with indices 11 and 22 were after the last visit to cafe with index 33 ; so this cafe is the answer.

In second test case, there are also three cafes, but with indices 11 , 22 and 44 . Cafes with indices 11 and 44 were visited after the last visit of cafe with index 22 , so the answer is 22 . Note that Vlad could omit some numbers while numerating the cafes.

首页