记录编号 |
8358 |
评测结果 |
AAAAAAATAT |
题目名称 |
美酒节赛羊 |
最终得分 |
80 |
用户昵称 |
thegy |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
2.961 s |
提交时间 |
2008-11-13 18:02:34 |
内存使用 |
0.11 MiB |
显示代码纯文本
program goat;
var
fin,fout: text;
f:array[0..1,0..100]of longint;
k1,k2:array[1..3]of longint;
p0,s,i,j,p,kk,tt: longint;
procedure updata(var x:longint;y:longint);
begin
if y>x then x:=y;
if x>=s then begin
writeln(fout,i);
close(fin);
close(fout);
halt;
end;
end;
function hf(x:longint):boolean;
begin
if (0<=x) and (x<=p0) then hf:=true
else hf:=false;
end;
begin
k1[1]:=1; k1[2]:=-2; k1[3]:=-5;
k2[1]:=1; k2[2]:=5; k2[3]:=10;
assign(fin,'goat.in'); reset(fin);
assign(fout,'goat.out'); rewrite(fout);
read(fin,s,p0);
p0:=p0-1;
f[0,0]:=0;
for i:=1 to p0 do f[0,i]:=-99999;
p:=0;
for i:=1 to 25000000 do begin
p:=1-p;
tt:=f[1-p,0]+1;
if tt>f[p,0] then f[p,0]:=tt;
for j:=0 to p0 do begin
for kk:=1 to 3 do
if (0<=j+k1[kk]) and (j+k1[kk]<=p0) then begin
tt:=f[1-p,j+k1[kk]]+k2[kk];
if tt>f[p,j] then f[p,j]:=tt;
end;
if f[p,j]>=s then begin
writeln(fout,i);
close(fin);
close(fout);
halt;
end;
end;
end;
end.