记录编号 138367 评测结果 AAAAAAAAAA
题目名称 [NOIP 2005]过河 最终得分 100
用户昵称 Gravatar思邈然 是否通过 通过
代码语言 Pascal 运行时间 0.002 s
提交时间 2014-11-05 20:38:06 内存使用 0.24 MiB
显示代码纯文本
program cogs111;
var
a:array[0..110]of longint;
f,b:array[1..10000] of longint;
s,t,m,l,i,j,p:longint;
function min(a,b:longint):longint;
begin
 if a<b then exit(a) else exit(b);
end;
begin
assign(input,'river.in');reset(input);
assign(output,'river.out');rewrite(output);
readln(l);
readln(s,t,m);
for i:=1 to m do read(a[i]);
filldword(f,sizeof(f)div 4,maxlongint);
if s=t then begin
for i:=1 to m do
if a[i] mod t=0 then inc(j);
writeln(j);  halt;end;
 for i:=1 to m do
   for j:=i+1 to m do
   if a[i]>a[j] then begin
     p:=a[i];a[i]:=a[j];a[j]:=p;
     end;
for i:=1 to m do begin
p:=a[i]-a[i-1]-t;
if p>0 then
 for j:=i to m do dec(a[j],p);  end;
l:=min(a[m]+t,l);
for i:=1 to m do b[a[i]]:=1;
for i:=s to l do
begin
   if i>t then
     for j:=i-t to i-s do
       f[i]:=min(f[i],f[j])
     else
     for j:=1 to i-s do
      f[i]:=min(f[i],f[j]);
   if f[i]=maxlongint then f[i]:=0;
   f[i]:=f[i]+b[i];
end;
writeln(f[l]);

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