|
|
back to boardPlease, help me to understand mistake My algo: uses SysUtils; var ex: Integer; Prep: integer; i, k: integer; Imposs: boolean = false; MinP: integer; MaxP: integer; fir ,sec: integer; begin // Readln( prep, ex ); MinP:= -1000; MaxP:= +1000; if Prep > 0 then for i:= 1 to prep do begin Readln( k ); if ( k < 0 ) and ( k > MinP ) then MinP:= k; if ( k > 0 ) and (k < MaxP ) then MaxP:= k; if ( ( ex > 0 ) and ( MaxP < ex ) ) or ( ( ex < 0 ) and ( MinP > ex ) ) then Imposs:= true; end; // for if not Imposs then begin if Ex > 0 then begin Fir:= Ex; Sec:= 2 * Abs( MinP ) + Ex; end else if Ex < 0 then begin Fir:= 2 * MaxP + Abs( Ex ); Sec:= Abs( Ex ); end; end; if not Imposs then Writeln( Fir, ' ', Sec ) else Writeln( 'Impossible' ); // end. wrong answer in test 1! |
|
|