[백준/파이썬] 10406번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 10406번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
Box is a really violent sport. To compensate, there is a code of conduct to maintain chivalry and fellowship atop the ring in friendly matches. One of the most well known rules of this code of conduct is to avoid hitting the opponent below the waist or above the neck.
Given the heights of the waist and neck of an opponent, and the heights of a set of punches, calculate how many of those punches are fair according to the rule above.
입력 요약
The first line contains three integers W, N and P, representing respectively the height of the waist of the opponent, the height of his neck, and the number of thrown punches (1 ≤ W < N ≤ 200 and 1 ≤ P ≤ 100). The second line contains P integers H1, H2, . . . …
출력 요약
Output a line with an integer representing the number of punches that are fair, according to the code of conduct.
코드
w,n,p=map(int,input().split())
print(len(list(filter(lambda x:w<=x<=n,map(int,input().split())))))
설명
핵심은 구현 관점에서 Box is a really violent sport. To compensate, there is a code of conduct to maintain chivalry and fellowship atop the ring in friendly matches. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기