Cyclopian Census

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
PEG 11/12 Programming Test 1 - October 19

FurWear is running out of oxygen!

After an emergency meeting between the Oelfinn and FurWear, and the ingestion of Earth-imported beer, the Oelfinn have decided to contract FurWear to perform analysis on their most recent census data (which now includes Oelfinn living on other planets). The Oelfinn wish to find how old the ith youngest Oelfinn is.

Due to their abnormally long lifespans and quirky reproductive cycles, it is guaranteed that no two Oelfinn will be the same age.

Input Specification

The first line consists of a single integer N (1 < N \le 60\,000), the number of live Oelfinn. The following N lines each contain a single integer a_{i} (10 \le a_{i} \le 1\,000\,000), the age of the ith Oelfinn (in millenia). The next line consists of a single integer Q (1 \le Q \le 100), the number of queries to follow. The following Q lines each contain a single integer q_{i} (1 \le q_{i} \le N), the ith query.

Output Specification

Output the correct answer to each query in the order given, on separate lines.

Sample Input

10
42
23
15
52
63
24
73
54
66
10
3
1
5
10

Sample Output

10
42
73

Comments


  • 0
    planT_444  commented on Sept. 24, 2020, 9:11 p.m.

    shouldn't it be the ith youngest? The second query is 5, and the 5th oldest is 52. The tenth youngest is 73, which is the correct answer.