seventh找不同

TimeLimit:3000MS  MemoryLimit:768MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers li and ri. For each query, you have to find any integer that occurs exactly once in the subarray of a from index li to index ri (a subarray is a contiguous subsegment of an array). For example, if a=[1,1,2,3,2,4], then for query (li=2,ri=6) the subarray we are interested in is [1,2,3,2,4], and possible answers are 13 and 4; for query (li=1,ri=2) the subarray we are interested in is [1,1], and there is no such element that occurs exactly once.

Can you answer all of the queries?


Input

The first line contains one integer n (1n5105).

The second line contains n integers a1,a2,,an (1ai5105).

The third line contains one integer q (1q5105).

Then q lines follow, i-th line containing two integers li and ri representing i-th query (1lirin).


Output

Answer the queries as follows:

If there is no integer such that it occurs in the subarray from index li to index ri exactly once, print 0. Otherwise print any such integer.


SampleInput
6
1 1 2 3 2 4
2
2 6
1 2
SampleOutput
4
0
Submit
题目统计信息详细
总AC数24
通过人数15
尝试人数21
总提交量86
AC率17.44%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: