728x90
9635번: Balloons Colors
Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100). Followed by the test cases, the first line of each test case contains 3 integers separated by a singl
www.acmicpc.net
문제 풀이
입력값마다 문제의 조건을 통해 출력해준다. 첫째 줄에 문제의 갯수 N, 컬러 X, Y가 주어진다. 두번 째 줄에서는 문제의 리스트가 주어진다.
- X, Y가 각각 문제의 리스트의 처음, 끝과 값이 같다면 "BOTH" 출력
- X만 리스트의 처음과 같다면, "EASY" 출력
- Y만 리스트의 끝과 같다면 "HARD" 출력
- 위 조건이 다 아니라면 "OKAY" 출력
정답 코드
for _ in range(int(input())) :
N, X, Y = map(int, input().split())
lst = [*map(int, input().split())]
if lst[0] == X and lst[-1] == Y : print("BOTH")
elif lst[0] == X : print("EASY")
elif lst[-1] == Y : print("HARD")
else : print("OKAY")
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 9699 - RICE SACK [python] (0) | 2023.03.27 |
---|---|
[BOJ/백준] 9698 - SAHUR & IMSA’ [python] (0) | 2023.03.27 |
[BOJ/백준] 9622 - Cabin Baggage [python] (0) | 2023.03.26 |
[BOJ/백준] 9550 - 아이들은 사탕을 좋아해 [python] (0) | 2023.03.26 |
[BOJ/백준] 9517 - 아이 러브 크로아티아 [python] (0) | 2023.03.26 |