比赛 NOIP2008集训模拟2 评测结果 TTWWWEEEEE
题目名称 美酒节赛羊 最终得分 0
用户昵称 0彼岸0 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-11 11:29:05
显示代码纯文本
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),$F7);
        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.