Who can tell me what's wrong with my code? Only 50 lines!!
I keep getting wa on test 3.
I think my program is quite easy to understand and it's very short. Many thanks if you would love to help me.
Or you can send your solution to me: fujieyun@163.com
Const MaxN = 1000;
Zero = 1e-8;
Var B1, B2 : Array [1..MaxN,1..2] of LongInt;
G1, G2 : Array [1..MaxN] of Record
W, Loc : Double;
End;
N, H, N1, N2, I, J, P : Integer;
Begin
ReadLn( H );
if H = 0
then Begin
WriteLn( 'Yes' ); Halt;
End;
ReadLn( N1 );
For I := 1 to N1 do
Begin
ReadLn( B1[I,1],B1[I,2] );
G1[I].W := B1[I,2]-B1[I,1];
G1[I].Loc := (B1[I,1]+B1[I,2])/2;
End;
For I := 2 to H do
Begin
ReadLn( N2 ); P := 1;
FillChar( G2, Sizeof(G2), 0 );
FillChar( B2, Sizeof(B2), 0 );
For J := 1 to N2 do
Begin
ReadLn(B2[J,1], B2[J,2] );
G2[J].W := B2[J,2] - B2[J,1];
G2[J].Loc := (B2[J,1] + B2[J,2])/2;
if (P<=N1)and(G1[P].Loc < B2[J,1]+Zero)
then Begin
WriteLn( 'No' ); Halt;
End;
While (P<=N1)and(G1[P].Loc+Zero < B2[J,2]) do
Begin
G2[J].Loc := G2[J].Loc + (G1[P].Loc-G2[J].Loc)*G2[J].W/(G1[P].W+G2[J].W);
G2[J].W := G2[J].W + G1[P].W;
Inc( P );
End;
End;
if P<=N1
then Begin
WriteLn( 'No' ); Halt;
End;
B1 := B2; G1 := G2; N1 := N2;
End;
WriteLn( 'Yes' );
End.