- 接水问题
- 2016-05-07 09:01:37 @
**var
a:array[1..10000] of longint;
b:array[1..100] of longint;
i,m,n,max,min,k,h:longint;
begin
readln(n,m);
for i:=1 to n do read(a[i]);
if m>n then begin
max:=-maxlongint;
for i:=1 to n do if max<a[i] then max:=a[i];
writeln(max);
exit;
end else begin
for i:=1 to m do b[i]:=a[i];
k:=m;
max:=-maxlongint;
repeat
min:=maxlongint;
for i:=1 to m do begin
if b[i]<min then begin
min:=b[i];
h:=i;
end;
end;
if k<=n-1 then begin
inc(k);
b[h]:=b[h]+a[k];
end;
until k=n;
for i:=1 to m do if b[i]>max then max:=b[i];
writeln(max);
end;
end.**
3 条评论
-
我是百度啦啦啦 LV 8 @ 2016-11-16 15:22:32
请发到题解区
-
2016-05-08 13:45:35@
var a:array[1..120] of longint;
b,i,k,j,n,m,x:longint;
begin
readln(n,m);
for i:=1 to m do read(a[i]);
for i:=m+1 to n do
begin
read(b);
k:=1;
for j:=2 to m do
if a[j]<a[k] then k:=j;
a[k]:=a[k]+b;
end;
x:=0;
for i:=1 to m do
if a[i]>x then x:=a[i];
writeln(x);
end. -
2016-05-07 09:01:50@
md智障
- 1
信息
- ID
- 1811
- 难度
- 4
- 分类
- (无)
- 标签
- 递交数
- 1852
- 已通过
- 785
- 通过率
- 42%
- 被复制
- 15
- 上传者