Created
December 5, 2014 17:15
-
-
Save stu43005/72cae20db0e95ef27992 to your computer and use it in GitHub Desktop.
エンジニアでも恋がしたい〜転職初日にぶつかった女の子が同僚だった件〜|paizaオンラインハッカソン4 Lite https://paiza.jp/poh/enkoi
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 | |
$N = intval(fgets(STDIN)); | |
$sum = 0; | |
for ($i=0;$i<$N;$i++) { | |
$sum += intval(fgets(STDIN)); | |
} | |
echo $sum; | |
?> |
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 | |
$N = intval(fgets(STDIN)); | |
$sum = 0; | |
for ($i=0;$i<$N;$i++) { | |
$aaa = explode(" ", fgets(STDIN)); | |
if (intval($aaa[0]) > intval($aaa[1])) { | |
$sum += (intval($aaa[0]) - intval($aaa[1])) * intval($aaa[2]); | |
} | |
} | |
echo $sum; | |
?> |
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 | |
list($t, $n) = explode(" ", fgets(STDIN)); | |
$sum = array(); | |
$max = 0; | |
for ($i=0; $i < $n; $i++) { | |
$m = intval(fgets(STDIN)); | |
for ($j=0; $j < $t; $j++) { | |
$k = $t - $j - 1; | |
if ($i >= $k && $i < $n - $j) { | |
$sum[$i - $k] += $m; | |
if ($j == 0 && $sum[$i - $k] > $max) { | |
$max = $sum[$i - $k]; | |
} | |
} | |
} | |
} | |
echo $max; | |
?> |
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 | |
list($t, $n) = explode(" ", fgets(STDIN)); | |
$m = array(); | |
$sum = 0; | |
$max = 0; | |
for ($i=0; $i < $n; $i++) { | |
$m[$i] = intval(fgets(STDIN)); | |
$sum += $m[$i]; | |
if ($i >= $t) { | |
$sum -= $m[$i - $t]; | |
} | |
if ($i >= $t - 1 && $sum > $max) { | |
$max = $sum; | |
} | |
} | |
echo $max; | |
?> |
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 | |
list($t, $n) = explode(" ", fgets(STDIN)); | |
$m = array(); | |
for ($i=0; $i < $n; $i++) { | |
$m[$i] = intval(fgets(STDIN)); | |
} | |
$max = 0; | |
for ($i=0; $i < $n-$t+1; $i++) { | |
$sum = 0; | |
for ($j=0; $j < $t; $j++) { | |
$sum += $m[$i+$j]; | |
} | |
if ($sum > $max) $max = $sum; | |
} | |
echo $max; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment