比赛 NOIP2017普及组模拟赛Mike 评测结果 AAWATTTTTT
题目名称 嘉豪 最终得分 30
用户昵称 mine 运行时间 6.139 s
代码语言 Pascal 内存使用 7.79 MiB
提交时间 2017-09-29 20:44:25
显示代码纯文本
var
v,n,g,ans:longint;
a,r:array[1..1000000] of longint;
procedure sort(s,t:longint);
var
 m,i,j,k:longint;
begin
 if s=t then exit;
 m:=(s+t) div 2;
 sort(s,m);
 sort(m+1,t);
 i:=s; j:=m+1; k:=s;
 while (i<=m) and (j<=t) do
  if a[i]<=a[j] then
  begin r[k]:=a[i]; inc(i); inc(k); end
  else begin
  r[k]:=a[j]; inc(j); inc(k); end;
  while i<=m do begin r[k]:=a[i]; inc(i); inc(k); end;
  while j<=t do begin r[k]:=a[j]; inc(j); inc(k); end;
  for i:=1 to t do a[i]:=r[i];
  end;

begin
assign(input,'jiahao1.in'); reset(input);
assign(output,'jiahao1.out'); rewrite(output);
read(v,n);
for g:=1 to n do read(a[g]);
 sort(1,n);
for g:=1 to n do
 if v>a[g] then
  begin inc(ans); v:=v+(a[g] div 2); end;
write(ans);
close(input);
close(output);
end.