这道题不是很难,二分答案+判定即可
注意在一套牌中Joker只能用一次
var a:array[..] of longint;
mid,l,r,n,m,i,ans:longint; function check(x:longint):boolean;
var i,t:longint;
begin
t:=m;
if t>x then t:=x; //判定的关键
for i:= to n do
if a[i]<x then
begin
t:=t-x+a[i];
if t< then exit(false);
end;
exit(true);
end; begin
readln(n,m);
for i:= to n do
read(a[i]);
l:=;
r:=;
while l<=r do
begin
mid:=(l+r) shr ;
if check(mid) then
begin
ans:=mid;
l:=mid+;
end
else r:=mid-;
end;
writeln(ans);
end.