Queries

5

2 votes
Very-Easy
Problem

Given an array of N elements and Q queries. Each query containing an integer X. For each query print the Xth smallest number of the input array.

Note : Don't use any predefined function. Try to make your own code.

Constraints
1 <= N <= 105
1 <= Value of element of array <= 1018
1 <= Q <= 106
1 <= X <= N

Input
First line contains value N. Next line contains N integers separated by a single space. Third line contains value Q. Next line contains Q integers separated by a space.

Sample Input
8
5 6 9 7 4 1 5 1
5
8 5 4 1 3
Sample Output
9
5
5
1
4
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?