https://www.acmicpc.net/problem/6764
문제
A fish-finder is a device used by anglers to find fish in a lake. If the fish-finder finds a fish, it will sound an alarm. It uses depth readings to determine whether to sound an alarm. For our purposes, the fish-finder will decide that a fish is swimming past if:
- there are four consecutive depth readings which form a strictly increasing sequence (such as 3 4 7 9) (which we will call “Fish Rising”), or
- there are four consecutive depth readings which form a strictly decreasing sequence (such as 9 6 5 2) (which we will call “Fish Diving”), or
- there are four consecutive depth readings which are identical (which we will call “Constant Depth”).
All other readings will be considered random noise or debris, which we will call “No Fish.”
Your task is to read a sequence of depth readings and determine if the alarm will sound.
입력
The input will be four positive integers, representing the depth readings. Each integer will be on its own line of input.
출력
The output is one of four possibilities. If the depth readings are increasing, then the output should be Fish Rising. If the depth readings are decreasing, then the output should be Fish Diving. If the depth readings are identical, then the output should be Fish At Constant Depth. Otherwise, the output should be No Fish.
예제 입력 1
1
10
12
13
예제 출력 1
Fish Rising
# 총 4개의 수를 받고
# 수들의 순서가 증가수열이면, "Fish Rising" 출력
# 감소수열이면 "Fish Diving" 출력
# 모든 수들이 다 같은 값이면 "Fish At Constant Depth" 출력
# 다 아니면 "No Fish" 출력
import sys
depth = [int(sys.stdin.readline()) for _ in range(4)]
if depth[0] < depth[1] and depth[1] < depth[2] and depth[2] < depth[3]:
print("Fish Rising")
elif depth[0] > depth[1] and depth[1] > depth[2] and depth[2] > depth[3]:
print("Fish Diving")
elif max(depth) == min(depth):
print("Fish At Constant Depth")
else:
print("No Fish")
'Problem Solving > BOJ' 카테고리의 다른 글
[백준, BOJ 6768] Don’t pass me the ball! (python) (0) | 2021.12.17 |
---|---|
[백준, BOJ 11866] 요세푸스 문제 0 (python) (0) | 2021.12.17 |
[백준, BOJ 6763] Speed fines are not fine! (python) (0) | 2021.12.16 |
[백준, BOJ 5928] Contest Timing (python) (0) | 2021.12.16 |
[백준, BOJ 11651] 좌표 정렬하기 2 (python) (0) | 2021.12.16 |