AUCTION - Going Once, Going Twice, Gone!
Tác giả: RR
Ngôn ngữ: Pascal
uses math;
var
cnt:array[1..1000000] of longint;
res,m,n,u,i:longint;
begin
read(m,n);
for i:=1 to n do
begin
read(u);
inc(cnt[u]);
end;
for i:=999999 downto 1 do
inc(cnt[i],cnt[i+1]);
u:=1;
for i:=1 to 1000000 do
if i*min(m,cnt[i])>res then
begin
res:=i*min(m,cnt[i]);
u:=i;
end;
writeln(u,' ',res);
end.