- 装箱问题
- 2018-07-17 21:40:04 @
var
v,n,i,j,q:integer;
a:array[0..30] of integer;
begin
readln(n,v);
for i:=1 to v do
read(a[i]);
for i:=1 to v do
for j:=i to v do
if a[i]<a[j] then
begin
q:=a[i];
a[i]:=a[j];
a[j]:=q;
end;
i:=0;
repeat
i:=i+1;
if a[i]<=n then
n:=n-a[i];
until (n=0) or (i=v);
writeln(n);
end.
1 条评论
-
Van Dark Holme LV 5 @ 2018-07-20 16:08:28
意外啊!
- 1