比赛 noip-081029 评测结果 AAAAAAA
题目名称 最小乘车费用 最终得分 100
用户昵称 maxiem 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-29 20:56:06
显示代码纯文本
  1. program busses;
  2. var
  3. f:array [1..10] of byte;
  4. dp:array [1..320000] of dword;
  5. n,i:dword;
  6. procedure go(n:dword);
  7. var
  8. i:dword;
  9. tmp:dword;
  10. begin
  11. if n<>1 then begin
  12. tmp:=maxlongint;
  13. for i:=1 to (n-1) div 2+1 do begin
  14. if dp[i]=0 then go(i);
  15. if dp[n-i]=0 then go(n-i);
  16. if dp[i]+dp[n-i]<tmp then tmp:=dp[i]+dp[n-i];
  17. end;
  18. if n<=10 then if tmp>f[n] then tmp:=f[n];
  19. dp[n]:=tmp;
  20. end;
  21. end;
  22. begin
  23. fillchar (dp,sizeof(dp),0);
  24. assign (input,'busses.in');
  25. reset (input);
  26. for i:=1 to 10 do read (f[i]);
  27. readln (n);
  28. close (input);
  29. assign (output,'busses.out');
  30. rewrite (output);
  31. dp[1]:=f[1];go(n);
  32. writeln (dp[n]);
  33. close (output);
  34. end.