记录编号 7709 评测结果 WWAWWEEEEE
题目名称 美酒节赛羊 最终得分 10
用户昵称 Gravatar0彼岸0 是否通过 未通过
代码语言 Pascal 运行时间 4.084 s
提交时间 2008-11-11 13:18:47 内存使用 115.70 MiB
显示代码纯文本
program goat;
var a:array[0..300000,0..100] of longint;
    i,j,k,s,p:longint;

begin
        assign(input,'goat.in');
        assign(output,'goat.out');
        reset(input);
        rewrite(output);
	readln(s,p);
	fillchar(a,sizeof(a),$7F);
        a[0,0]:=0;
	for i:=1 to s do
		for j:=1 to p do
		begin
			if (i-1>=0) and (j+1<p) and (a[i,j]>a[i-1,j+1]+1) then a[i,j]:=a[i-1,j+1]+1;
			if (i-5>=0) and (j-2>=0) and (a[i,j]>a[i-5,j-2]+1) then a[i,j]:=a[i-5,j-2]+1;
			if (i-10>=0) and (j-5>=0) and (a[i,j]>a[i-10,j-5]+1) then a[i,j]:=a[i-10,j-5]+1;
		end;

	k:=maxlongint;
	for i:=0 to p do
		if k>a[s,i] then k:=a[s,i];

	writeln(k);
        close(input);
        close(output);
end.