728x90
문제 풀이
첫 줄에 주어진 K를 가지고 각각의 입력값을 전 입력값과 비교했을 때 차이가 K이상일 경우의 수를 구해 출력한다.
정답 코드
n, K = map(int, input().split())
ans = 0
t = int(input())
for _ in range(n - 1) :
tmp = int(input())
if t - tmp >= K : ans += 1
t = tmp
print(ans)
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 9924 - The Euclidean Algorithm [python] (0) | 2023.03.28 |
---|---|
[BOJ/백준] 9907 - ID [python] (0) | 2023.03.28 |
[BOJ/백준] 9838 - XMAX [python] (0) | 2023.03.27 |
[BOJ/백준] 9783 - Easy Encryption [python] (0) | 2023.03.27 |
[BOJ/백준] 9776 - Max Volume [python] (0) | 2023.03.27 |