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 C++ (GCC 9.2.1) (judge verdict: Accepted)

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
pair<ll,ll> norm(ll a,ll b)
{
  if(a<0)
  {
    a*=-1;
    b*=-1;
  }
  else if ((a==0)&&(b<0))
  {
    b*=-1;
  }
  ll d=__gcd(abs(a),abs(b));
  a=(ll)(a/d);
  b=(ll)(b/d);
  pair <ll,ll> p=mp(a,b);
  return p;
}
bool decreasing(pair<ll,ll> a,pair<ll,ll> b) 
{ 
       if(a.first>b.first)
       return true;
       else if(a.first==b.first)
       {
        if(a.second<b.second)
        return false;
        else
        return true;
       } 
       else
       return false;
} 
ll expo(ll x,ll y) 
{ 
    ll res = 1;  
    while(y>0) 
    {  
        if(y&1) 
        res=(res*x)%1000000007;  
        y=y>>1;
        x=(x*x)%1000000007; 
    } 
    return res; 
}
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // {
      ll a,b,c,d,ans=-1e19,i,j,k;
      cin>>a>>b>>c>>d;
      if((b>=0)&&(d>=0))
      {
        i=b*d;
        ans=max(ans,i);
      }
      if((a<=0)&&(c<=0))
      {
        i=a*c;
        ans=max(ans,i);
      }
      if((b<=0)&&(c>=0))
      {
        i=b*c;
        ans=max(i,ans);
      }
      if((b<=0)&&(c<=0))
      {
        i=b*c;
        ans=max(i,ans);
      }
      if(d<=0)
      {
        i=d*a;
        ans=max(i,ans);
      }
      cout<<ans;
      return 0;
}