Problem:
Score : 200 points

Problem Statement

Given are integers a,b,c and d.
If x and y are integers and a \leq x \leq b and c\leq y \leq d hold, what is the maximum possible value of x \times y?

Constraints

-10^9 \leq a \leq b \leq 10^9

-10^9 \leq c \leq d \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

a b c d

Output

Print the answer.

Sample Input 1

1 2 1 1

Sample Output 1

2

If x = 1 and y = 1 then x \times y = 1.
If x = 2 and y = 1 then x \times y = 2.
Therefore, the answer is 2.

Sample Input 2

3 5 -4 -2

Sample Output 2

-6

The answer can be negative.

Sample Input 3

-1000000000 0 -1000000000 0

Sample Output 3

1000000000000000000

Solution in JavaScript (Node.js 12.16.1) (judge verdict: Wrong Answer)

//abから、x候補を探す
function ab(a,b){ 
    let x = [];
    if( a < 0 && b > 0){ //0をまたぐ場合
        x.push(a,b);
    }else{
        x.push(a,b)
    }
    return x;
}

//cdから、y候補を探す
function cd(c,d){ 
    let x = [];
    if( c < 0 && d > 0){ //0をまたぐ場合
        x.push(c,d);
    }else{
        x.push(c,d)
    }
    return x;
}

function Main(input) {
	input = input.split(" ");  
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
    var c = parseInt(input[2], 10);
    var d = parseInt(input[3], 10);
    let x = ab(a,b);//x候補配列
    let y = cd(c,d);//y候補配列
    let arr = [];//結果候補配列

    for(let i = 0; i < x.length; i++){
        for(let j = 0; j < y.length; j++){
            let kai = x[i] * y[j] +0;
            arr.push(kai);
        }
    }
    var result = arr.reduce(function(a, b) {//配列の最大値
        return Math.max(a, b);
    });

    console.log(result.toString());
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));