比赛 |
noip-081029 |
评测结果 |
AAAAAAA |
题目名称 |
最小乘车费用 |
最终得分 |
100 |
用户昵称 |
maxiem |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-10-29 20:56:06 |
显示代码纯文本
- program busses;
- var
- f:array [1..10] of byte;
- dp:array [1..320000] of dword;
- n,i:dword;
- procedure go(n:dword);
- var
- i:dword;
- tmp:dword;
- begin
- if n<>1 then begin
- tmp:=maxlongint;
- for i:=1 to (n-1) div 2+1 do begin
- if dp[i]=0 then go(i);
- if dp[n-i]=0 then go(n-i);
- if dp[i]+dp[n-i]<tmp then tmp:=dp[i]+dp[n-i];
- end;
- if n<=10 then if tmp>f[n] then tmp:=f[n];
- dp[n]:=tmp;
- end;
- end;
- begin
- fillchar (dp,sizeof(dp),0);
- assign (input,'busses.in');
- reset (input);
- for i:=1 to 10 do read (f[i]);
- readln (n);
- close (input);
- assign (output,'busses.out');
- rewrite (output);
- dp[1]:=f[1];go(n);
- writeln (dp[n]);
- close (output);
- end.