woshiniba 2009-02-27 04:57:00
点我顶贴
收藏
删除
附10分代码:
program rq100;
var
height:array [1..10000] of longint;
n,w,i,j,k,len,min,from,minfrom:longint;
o:boolean;
begin
fillchar(height,sizeof(height),0);
readln(n,w);
for i:=1 to n do
begin
readln(len);
min:=maxlongint;
minfrom:=0;
for j:=1 to w-len+1 do
begin
o:=true;
for k:=j to j+len-2 do
if height[k]<height[k+1] then o:=false;
if (o=true) and (height[j]<min) then begin
min:=height[j];
minfrom:=j;
end;
end;
for k:=minfrom to minfrom+len-1 do
inc(height[k],len);
end;
min:=-maxlongint;
for i:=1 to w do
if height[i]>min then min:=height[i];
writeln(min);
readln;
end.