Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求错帖...大神啊......交了n次了... code Program poj2373; var n,m:longint; a,b,bg,ed,k,i,h,t,p:longint; f,q :Array[0..1000001] of longint; g :Array[0..1000001] of boolean; begin readln(n,m); readln(a,b); for i:=1 to n do begin readln(bg,ed); for k:=bg+1 to ed-1 do g[k]:=true; end; for i:=1 to m do f[i]:=1<<30; f[0]:=0; h:=1; t:=1; q[1]:=0; for i:=a to m>>1 do begin p:=i<<1; if g[p] then continue; while (h<t) and (q[h]<p-(b<<1)) do inc(h); if q[h]>p-(a<<1) then continue; f[p]:=f[q[h]]+1; while (h<t) and (f[q[t]]>f[p]) do dec(t); inc(t); q[t]:=p; end; if f[m]=1<<30 then writeln(-1) else writeln(f[m]); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator