首页 > 代码库 > HourRank 20

HourRank 20

A.Hot and Cold(水题)

Carl, Caroline, Helen, and Han are four friends sharing a one-room workspace. The workspace has a single thermostat which they can set to any integer temperature between degrees to degrees Fahrenheit, inclusive.

The four friends can‘t agree on the room‘s temperature! Carl and Christina don‘t want it to be too cold, while Helen and Han don‘t want it to be too hot. Specifically:

  • Carl wants it to be at least degrees Fahrenheit.

  • Caroline wants it to be at least degrees Fahrenheit.

  • Helen wants it to be at most degrees Fahrenheit.

  • Han wants it to be at most degrees Fahrenheit.

Given , , , and , is there a satisfactory temperature that all four friends will be happy with? If it‘s possible, print YES; otherwise, print NO.

Input Format

Four space-separated integers describing the respective values of , , , and .

Constraints

Output Format

Print YES if it‘s possible to satisfy all four friends‘ conditions; otherwise, print NO instead.

Sample Input 0

50 40 70 60

Sample Output 0

YES

Explanation 0

The four friends have the following temperature preferences:

  • Carl wants it to be at least degrees.

  • Caroline wants it to be at least degrees.

  • Helen wants it to be at most degrees.

  • Han wants it to be at most degrees.

技术分享

Any temperature between and degrees will satisfy all four friends, so we print YES.

Sample Input 1

55 66 66 77

Sample Output 1

YES

Explanation 1

The four friends have the following temperature preferences:

  • Carl wants it to be at least degrees.

  • Caroline wants it to be at least degrees.

  • Helen wants it to be at most degrees.

  • Han wants it to be at most degrees.

技术分享

A temperature of exactly degrees will satisfy all four friends, so we print YES.

Sample Input 2

80 80 40 40

Sample Output 2

NO

Explanation 2

In this test case, Carl wants the temperature to be at least and Helen wants it to be at most . There is no temperature that is both and , so we print NO because no satisfactory temperature exists.

技术分享

技术分享

Code:

技术分享
 1 #include <bits/stdc++.h> 2 using namespace std; 3 int c1 , c2 , h1 , h2; 4 int main() 5 { 6     scanf("%d%d%d%d" , &c1 , &c2 , &h1 , &h2); 7     if(min(h1 , h2) < max(c1 , c2)) 8         puts("NO"); 9     else10         puts("YES");11 }
View Code

 

HourRank 20