W55555555求救

P1409 纪念品分组

type must=record

   W:longint;

   T:boolean;

   end;

var Have,Max,for2:integer;

  answer:longint;

  Thing:array[1..30000] of must;

procedure init;

var for1:integer;

begin

readln(Max);

readln(Have);

for for1:=1 to Have do begin

readln(Thing[for1].W);

Thing[for1].T:=true;

end;

end;

procedure working;

var for1,for2,need:integer;

   box:must;

begin

answer:=0;

need:=Have;

for for1:=1 to Have-1 do

for for2:=for1+1 to Have do if Thing[for1].w>Thing[for2].w then begin

  box:=thing[for1];

  thing[for1]:=thing[for2];

  thing[for2]:=box;

end;

for for1:=1 to Have-1 do begin

if thing[for1].t=false then continue;

for for2:=Have downto for1+1 do begin

  if thing[for2].t=false then continue;

  if thing[for1].w+thing[for2].w

0 条评论

目前还没有评论...

信息

ID
1409
难度
4
分类
贪心 点击显示
标签
递交数
8106
已通过
3194
通过率
39%
被复制
27
上传者