|
|
вернуться в форумWhy i got WA?Please help(Code inside) program p1203t; const maxt=30000; type arr1=array [0..maxt] of integer; rec=record ts,te:integer; end; arr2=array [0..maxt] of rec; var a:arr1; n:integer; con:arr2; {$APPTYPE CONSOLE} procedure init; var i,ts,te,j,k:integer; t:arr1; begin readln(n); fillchar(t,sizeof(t),0); j:=0; for i:=1 to n do begin readln(ts,te); if (ts>te) then begin k:=ts; ts:=te; te:=k; end; if (ts=0) then ts:=-1; if (t[te]<ts) then t[te]:=ts; end; for i:=0 to maxt do if (t[i]<>0) then begin inc(j); if (t[i]=-1) then t[i]:=0; con[j].ts:=t[i]; con[j].te:=i; end; for i:=0 to maxt do a[i]:=0; n:=j; end; procedure solve; var i,j:integer; begin for i:=1 to n do begin for j:=(con[i-1].te+1) to con[i].te do a[j]:=a[con[i-1].te]; if (a[con[i].ts-1]+1>a[con[i].te]) then a[con[i].te]:=a[con [i].ts-1]+1; end; end; procedure sout; begin writeln(a[con[n].te]); end; begin init; solve; sout; end. |
|
|