比赛 |
NOIP2008集训模拟2 |
评测结果 |
C |
题目名称 |
美酒节赛羊 |
最终得分 |
0 |
用户昵称 |
cuixiaofei |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-11 11:14:02 |
显示代码纯文本
program goat;
const
max =300000;
var
s,p :longint;
f :array[-20..max,-10..120] of longint;
f1,f2 :text;
procedure init;
begin
assign(f1,'goat.in');
reset(f1);
assign(f2,'goat.out');
rewrite(f2);
readln(f1,s,p);
filldword(f,sizeof(f) div 4,1000000000);
f[0,0]:=0;
end;
function xiao(x,y:longint):longint;
begin
xiao:=maxlongint;
if x<xiao then
xiao:=x;
if y<xiao then
xiao:=y;
end;
procedure main;
var
i,j :longint;
min,ge :longint;
begin
for i:=1 to s do
begin
for j:=1 to p do
begin
min:=maxlongint;
if j=p-10 then
begin
ge:=xiao(f[i-1,j+1]+1,xiao(f[i-5,j-2]+1,xiao(f[i-10,j-5]+1,f[i-10,j]+10)));
if ge<min then
min:=ge;
end
else
begin
ge:=xiao(f[i-1,j+1]+1,xiao(f[i-5,j-2]+1,f[i-10,j-5]+1));
if ge<min then
min:=ge;
end;
f[i,j]:=min;
end;
end;
end;
procedure print;
begin
writeln(f2,f[s,p]);
close(f1);
close(f2);
end;
begin
init;
main;
print;
end.