from collections import deque
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = map(int,input().split())
q = deque(list(map(int,input().split())))
cnt = 0
while q:
maxQ = max(q)
front = q.popleft()
m -= 1
if maxQ == front:
cnt += 1
if m < 0 :
print(cnt)
break
else:
q.append(front)
if m < 0 :
m = len(q) - 1
# m이 0보다 작아지는 경우는 그 위치만큼 q를 돌려서 확인했다는 것이기 때문에 m < 0 일때 cnt 값을 출력해주면 그것이 답이 된다.
'문제풀이 > 백준(Boj) 문제풀이' 카테고리의 다른 글
[백준][큐 & 덱] 5430. AC (파이썬/Python) (0) | 2021.12.07 |
---|---|
[백준][큐 &덱] 10886. 덱 (파이썬/Python) (0) | 2021.12.07 |
[백준][동적 계획법/DP] 11052. 카드 구매하기 (0) | 2021.12.03 |
[백준][동적 계획법/DP] 9095. 1, 2, 3 더하기 (0) | 2021.12.03 |
[백준][DFS] 2468. 안전 영역 (파이썬/Python) (0) | 2021.12.03 |