军方截获的信息由 n(n<=30000)个数字组成,因为是敌国的高端秘密,所以一
时不能破获。最原始的想法就是对这 n 个数进行小到大排序,每个数都对应一个
序号,然后对第 i 个是什么数感兴趣,现在要求编程完成。
【输入格式】
第一行 n,接着是 n 个截获的数字,接着一行是数字 k,接着是 k 行要输出数
的序号。
【输出格式】
k 行序号对应的数字。
【输入样例】Secret.in
5
121 1 126 123 7
3
2
4
3
【输出样例】Secret.out
7
123
121
program secret;
const max=30000;
var n,i,x,k:longint;
a:array[1..max] of longint;
procedure sort(l,r:longint);
var i,j,t,mid:longint;
begin
i:=l;j:=r;
mid:=a[(l+r)div 2];
repeat
while a[i]<mid do inc(i);
while a[j]>mid do dec(j);
if j>=i then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
inc(i);
dec(j)
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;