?!@!? 2012-03-27 05:19:00
点我顶贴
收藏
删除
var
p:array [1..30000] of longint;
i,j,w,n,b,c:longint;
s:qword;
begin
readln(w);
readln(n);
for i:=1 to n do
readln(p[i]);
for i:=n downto 1 do
for j:=1 to i-1 do
if p[j]>p[j+1] then
begin
c:=p[j];
p[j]:=p[j+1];
p[j+1]:=c;
end;
s:=0;
i:=1;
j:=n;
while n>1 do
if (p[i]+p[j])<=w then
begin
s:=s+1;
n:=n-2;
i:=i+1;
j:=j-1;
end
else
begin
s:=s+1;
n:=n-1;
j:=j-1;
end;
if n=1 then s:=s+1;
writeln(s);
end.
错哪里了?