讨论 / 终于过了~!!激动啊 啊啊啊啊 过河啊~!
Dev 2013-10-20 19:39:00
点我顶贴 收藏 删除
ac了

首先要排序;

然后压缩;

最后东归;

搞定s=t;

ac;

program qingwa;

var

a:array[-1000..101000] of longint;

f,r:array[-1000..1000000] of longint;

i,j,k,m,n,s,t,l,min,temp:longint;

procedure quick(h,t:longint);

var

i,j,k,s:longint;

begin

i:=h;

j:=t;

k:=a[(i+j) div 2];

repeat

while a[i]<k do inc(i);

while a[j]>k do dec(j);

if i<=j then begin

s:=a[i]; a[i]:=a[j]; a[j]:=s;

inc(i); dec(j);

end;

until i>j;

if i<t then quick(i,t);

if h<j then quick(h,j);

end;

begin

readln(l);

readln(s,t,m);

fillchar(f,sizeof(f),0);

a[0]:=0;

a[m+1]:=l;

for i:=1 to m do

read(a[i]);

quick(1,m);

if s=t then begin

min:=0;

for i:=1 to m do

if a[i] mod s=0 then

inc(min);

writeln(min);

halt;

end;

for i:=0 to m do begin

if a[i+1]-a[i]>temp+100 then

inc(temp,a[i+1]-a[i]-temp-100);

dec(a[i+1],temp);

end;

for I:=1 to m do

r[a[i]]:=1;

l:=a[m+1];

for i:=1 to l do

begin

min:=maxint;

for j:=s to t do

begin

if i>=j then

if r[i]+f[i-j]<min then

min:=r[i]+f[i-j];

f[i]:=min;

end;

end;

writeln(f[l]);

end.

#1 yumaosheng@2013-10-20 19:39:00
回复 删除
for i:=0 to m do begin

if a[i+1]-a[i]>temp+100 then

inc(temp,a[i+1]-a[i]-temp-100);

dec(a[i+1],temp);

end;

什么意思????

查看更多回复
提交回复