Mai intai trebuie sa te autentifici.
Cod sursa(job #30242)
Utilizator | Data | 13 martie 2007 16:32:03 | |
---|---|---|---|
Problema | Jocul Flip | Scor | 30 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 1.29 kb |
{
Jocul Flip...
Versiunea 2.00
}
Program Flip;
Type matrice = array[1..16,1..16] of Longint;
Var a : matrice;
n, m, i, j, k : Byte;
s, s1, s2 : Longint;
Begin
Assign( input, 'flip.in' );
Reset( input );
Readln( n, m );
For i := 1 to n do
For j := 1 to m do
Read( a[i,j] );
Close( input );
For i := 1 to n do
For j := 1 to m do
Begin
s1 := 0;
s2 := 0;
For k := 1 to m do
Begin
s1 := s1 + a[i,k];
s2 := s2 - a[i,k];
End;
if s2 > s1 then
For k := 1 to m do a[i,k] := -a[i,k];
s1 := 0;
s2 := 0;
For k := 1 to n do
Begin
s1 := s1 + a[k,j];
s2 := s2 - a[k,j];
End;
if s2 > s1 then
For k := 1 to n do a[k,j] := -a[k,j];
End;
s := 0;
For i := 1 to n do
For j := 1 to m do
s := s + a[i,j];
Assign( output, 'flip.out' );
Rewrite( output );
Writeln( s );
Close( output );
End.