TSECJ06 - Editorial

PROBLEM LINK:

Problem

Editorialist: Vishesh Sharma

DIFFICULTY -

Easy

PREREQUISITES -

Basic Programming

EXPLANATION -

Observations

Carl and Caroline’s preferences constrain how cold the room can be, so the temperature must be at least c1 and c2. This is the same as saying that the minimum acceptable temperature is max(c1,c2).
Helen and Han’s preferences constrain how hot the room can be, so the temperature must be at most h1 and h2. This is the same as saying that the maximum acceptable temperature is min(h1,h2).

Thus, the answer is YES if max(c1,c2)<=min(h1,h2) and NO otherwise.

Code(Python):

a, b, c, d = map(int, raw_input().split())
if max(a, b) <= min(c, d):
   print "YES"
else:
   print "NO"

Time Complexity-

O(1)