Created
November 7, 2017 18:06
-
-
Save dflima/f5854c1e91bd0f769839d35d0a28581e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$handle = fopen('php://stdin', 'r'); | |
fscanf($handle, '%d', $n); | |
$a = []; | |
for ($i = 0; $i < $n; $i++) { | |
$temp = fgets($handle); | |
$a[] = explode(' ', $temp); | |
array_walk($a[$i], 'invtal'); | |
} | |
$d1 = $d2 = $j = 0; | |
$length = count($a); | |
for ($i = 0; $i < $length; $i++) { | |
$d1 += $a[$j++][$i]; | |
$d2 += $a[$length-$j][$i]; | |
} | |
print abs($d1 - $d2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment