You are viewing a single comment's thread. Return to all comments →
I think a little cleaner PHP solution:
<?php fscanf(STDIN, '%d %d', $n, $m); $list = []; for ($i = 0; $i < $m; $i++) { list($a, $b, $k) = explode(' ', trim(fgets(STDIN)), 3); $list[$a-1] = ($list[$a-1] ?? 0) + $k; $list[$b] = ($list[$b] ?? 0) - $k; } ksort($list); $running_total = 0; $max = 0; foreach ($list as $value) { $running_total += $value; $max = max($max, $running_total); } print $max;
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
I think a little cleaner PHP solution: