Pagini recente » Cod sursa (job #1406041) | Cod sursa (job #92466) | Cod sursa (job #559507) | Cod sursa (job #2583598) | Cod sursa (job #964576)
Cod sursa(job #964576)
program statistici_de_ordine;
var n,z,i:longint;
a:array [1..3000000] of longint;
bufin:array[1..100000] of byte;
procedure select(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if z<=j then if l<j then select(l,j);
if z>=i then if r>i then select(i,r);
end;
begin
assign(input,'sdo.in');
reset(input);
settextbuf(input,bufin);
assign(output,'sdo.out');
rewrite(output);
readln(n,z);
{ for i:= 1 to n do read(a[i]);
select(1,n); }
writeln(a[z]);
close(output);
end.