比赛 暑假培训B班二测 评测结果 AAAAATTTTTT
题目名称 待售干草 最终得分 45
用户昵称 Fangel 运行时间 6.019 s
代码语言 Pascal 内存使用 0.18 MiB
提交时间 2012-07-22 11:25:15
显示代码纯文本
  1. var
  2. v,n,a,b,c,d,max,i,j:longint;
  3. ss:array[1..5000] of longint;
  4. procedure cz(x,sum:longint);
  5. begin
  6. if x>n then begin if sum>max then max:=sum;end
  7. else
  8. begin
  9. if sum+ss[x]<=v then cz(x+1,sum+ss[x]);
  10. cz(x+1,sum);
  11. end;
  12. end;
  13. begin
  14. assign(input,'hay4sale.in');reset(input);
  15. assign(output,'hay4sale.out');rewrite(output);
  16. read(v,n);
  17. for a:=1 to n do
  18. read(ss[a]);
  19. cz(1,0);
  20. write(max);
  21. close(input);
  22. close(output);
  23. end.