Pagini recente » Cod sursa (job #1465680) | Cod sursa (job #2444589) | Cod sursa (job #2904323) | Cod sursa (job #797858) | Cod sursa (job #1101656)
program statistici_de_ordine;
var a:array[1..3000005] of longint;
b1,b2:array[1..1 shl 16] of char;
n,i,k,nr:longint;
procedure sort(l,r:longint);
var i,j,mid,aux:longint;
begin
i:=l;
j:=r;
mid:=(i+j) div 2;
while i<=j do begin
while a[i]<a[mid] do inc(i);
while a[j]>a[mid] do dec(j);
if i<=j then begin
aux:=a[i];
a[i]:=a[j];
a[j]:=aux;
inc(i);
dec(j);
end;
end;
if k>=i then if i<r then sort(i,r);
if k<=j then if l<j then sort(l,j);
end;
begin
assign(input,'sdo.in'); reset(input);
settextbuf(input,b1);
assign(output,'sdo.out'); rewrite(output);
settextbuf(output,b2);
readln(n,k);
for i:=1 to n do read(a[i]);
sort(1,n);
writeln(a[k]);
close(output);
end.