본문 바로가기
공부/코딩테스트

백준: 21638번 SMS from MCHS (Python3)

by 혼밥맨 2022. 8. 9.
반응형

백준: 21638번 SMS from MCHS (Python3)

SMS from MCHS 성공다국어

 
시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB 815 473 448 60.459%

문제

You work for MCHS (Russian Ministry of Emergency Situations). You have just received a report from Hydro-meteorological Center containing an information about today's weather and the forecast for tomorrow.

According to this report, the air temperature is t1 degrees today, and the wind speed is v1 meters per second. Tomorrow the air temperature will be t2 degrees, and the wind speed will be v2 meters per second.

You are given a task to notify citizens about the weather for tomorrow via SMS.

The most important goal is to warn citizens in case the storm is possible. If, according to the forecast, the temperature tomorrow will be negative, and the wind speed will be at least 10 meters per second, you should send a message with following text:

A storm warning for tomorrow! Be careful and stay home if possible!

Otherwise, you may just notify citizens about bad weather changes.

If the temperature tomorrow will be lower than today, then you should send a message with a warning about a cold snap. It should have the following text:

MCHS warns! Low temperature is expected tomorrow.

Otherwise, if wind speed tomorrow will be higher than today, then you should send a message with a warning about strong wind. It should have the following text:

MCHS warns! Strong wind is expected tomorrow.

If none of the above conditions is satisfied, the you don't have to send a message at all.

Given the report from Hydro-meteorological Center, determine, what message has to be sent.

입력

The first line of input contains two integers t1 and v1 --- the temperature and the wind speed for today (−50≤t1≤50; 0≤v1≤20). The second line contains two integers t2 and v2 --- the temperature and the wind speed for tomorrow (−50≤t2≤50; 0≤v2≤20).

출력

In case if any message has to be sent, output its text. Otherwise, output phrase "No message". 

You can separate message words with spaces and line feeds arbitrarily.

예제 입력 1 

15 2
5 3

예제 출력 1 

MCHS warns! Low temperature
is expected tomorrow.

예제 입력 2 

15 1
17 1

예제 출력 2 

No message

답안

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# tmrw temp negative && wind speed >=10
# -->A storm warning for tomorrow! Be careful and stay home if possible!
 
# if tmrw's temp lower than today
# --> MCHS warns! Low temperature is expected tomorrow.
 
# if wind speed higher than today
# --> MCHS warns! Strong wind is expected tomorrow.
 
# Else: No message
 
# today's temp, wind
# tmrw's temp, wind
 
a,b = map(int, input().split())
c,d = map(int, input().split())
 
if c<0 and d>=10:
    print("A storm warning for tomorrow! Be careful and stay home if possible!")
elif c<a:
    print("MCHS warns! Low temperature is expected tomorrow.")
elif d>b:
    print("MCHS warns! Strong wind is expected tomorrow.")
else:
    print("No message")
cs
반응형

댓글