Skip to content

Instantly share code, notes, and snippets.

@flymio
Created September 30, 2018 12:38
Show Gist options
  • Save flymio/6aa5ddf8c1773b05365b8b196421ec95 to your computer and use it in GitHub Desktop.
Save flymio/6aa5ddf8c1773b05365b8b196421ec95 to your computer and use it in GitHub Desktop.
крутое решение на питоне:
a = input().strip().split(' ')
for i in range(0, len(a)):
a[i] = int(a[i])
s = sum(a)
print(str(s - max(a)) + " " + str(s - min(a)))
<?php
// Complete the miniMaxSum function below.
function miniMaxSum($arr) {
global $count;
$max=0; $min=0;
for($i=1;$i<=$count;$i++){
$sum = getNumber($i)+getNumber($i+1)+getNumber($i+2)+getNumber($i+3);
if ($sum>$max){
$max = $sum;
}
if ($sum < $min || $min == 0){
$min = $sum;
}
}
echo "$min $max\n";
}
function getNumber($i){
global $count;
global $arr;
if (isset($arr[$i])){
return $arr[$i];
}
else{
return $arr[$i % $count];
}
}
$stdin = fopen("php://stdin", "r");
fscanf($stdin, "%[^\n]", $arr_temp);
$arr = array_map('intval', preg_split('/ /', $arr_temp, -1, PREG_SPLIT_NO_EMPTY));
$count = count($arr);
miniMaxSum($arr);
fclose($stdin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment