Sort by

recency

|

11 Discussions

|

  • + 0 comments
    <?php
    
    $handle = fopen ("php://stdin", "r");
    function isSatisfiable($c1, $c2, $h1, $h2){
        // Complete this function
        $cmin = min($c1, $c2);
        $cmax = max($c1, $c2);
        $hmin = min($h1, $h2);
        $hmax = max($h1, $h2);
        if($cmin<=$hmin && $cmin<=$hmax && $cmax<=$hmin && $cmax<=$hmax){
            if(($hmin-$cmin) >= 0)
                return 'YES';
            else
                return 'NO';
        }
        else
            return 'NO';
    }
    
    // Return "YES" if all four conditions can be satisfied, and "NO" otherwise
    fscanf($handle, "%d %d %d %d", $c1, $c2, $h1, $h2);
    $result = isSatisfiable($c1, $c2, $h1, $h2);
    echo $result . "\n";
    
    ?>
    
  • + 0 comments

    If you hate conditions use hashing!!!

  • + 0 comments

    image image

  • + 0 comments

    include

    include

    include

    include

    include

    include

    include

    int main() { // Return "YES" if all four conditions can be satisfied, and "NO" otherwise int c1; int c2; int h1; int h2; scanf("%d %d %d %d", &c1, &c2, &h1, &h2); if((c1>=35&&c1<=95) && (c2>=30&&c1<=95) && (h1>=63&&h1<=95) && (h2>=59 && h2<=95)) { printf("YES"); } else{ printf("NO"); } return 0; } for one test case the input given is 35,35,35,35 and for other input 95,95,95,95 so how the ouput is yes for both the case...How?

  • + 0 comments
    static String isSatisfiable(int c1, int c2, int h1, int h2){
        //checking the initial condition for atleast and atmost    
            if((c1>=35) && (c2>=35) &&(h1<=95) && (h2<=95))
                {
                //checking the minimum temperature with max temperature
                if(h1>=c1 && h2>=c2)
                    {
                    //checking if atmost of 2nd temperature is less than atleast of 1st temperature . If so return "no"
                      if(h2<c1)
                          {
                          return "NO";
                      }
                    //checking if atmost of 1st temperature is less than atleast of 2nd temperature. If so return "no"
                    else if(h1<c2)
                        {
                        return "NO";
                    }
                    //if it satisfies all the condition . return "yes"
                    else
                        {
                    return "YES";
                    }
                
                }
                //if it fails with min temperature comparison with max temp return "no"
                else
                    {
                    return "NO";
                }
                
            }
            //if it fails the basic condition return "no"
            else 
                return "NO";
         
        }