Q1033 - Unit9 - 智力值 From Admin Normal (OI) 总时限:5s 内存限制:128MB 代码长度限制:64KB | |
描述 Description WJ是个很聪明的人,他有一个智力值。 |
输入格式 InputFormat 第一行包含两个正整数n和k,表示要和WJ辩论的人数,以及WJ的初始智力值。 |
输出格式 OutputFormat第一行包含一个正整数,表示WJ最终智力值的最大值。 |
样例输入 SampleInput [复制数据]5 9188 90 92 94 98 |
样例输出 SampleOutput [复制数据]99 |
数据范围和注释 Hint 数据范围: |
每次贪心贪比他聪明的人中最不聪明的
const
maxn=5000;
var
n,i,j,now,tot:longint;
a:array[1..maxn] of longint;
procedure qsort(l,r:longint);
var
i,j,m,p:longint;
begin
i:=l;
j:=r;
m:=a[(l+r) div 2];
repeat
while a[i]<m do inc(i);
while a[j]>m do dec(j);
if i<=j then
begin
p:=a[i];
a[i]:=a[j];
a[j]:=p;
inc(i);
dec(j);
end;
until i>j;
if (l<j) then qsort(l,j);
if (i<r) then qsort(i,r);
end;
begin
read(n,now);
tot:=0;
for i:=1 to n do read(a[i]);
qsort(1,n);
for i:=1 to n do
begin
if (now<a[i]) then inc(now,2)
else inc(tot);
end;
writeln(tot+now);
end.