case = int(input())
for i in range(case):
c, m = map(int, input().split())
num = list(map(int, input().split()))
while(len(num)!=0):
if m>0:
if num[0] == max(num):
m -= 1
num.pop(0)
elif num[0] < max(num):
m -= 1
num.append(num[0])
num.pop(0)
elif m==0:
if num[0] == max(num):
print(c-len(num)+1)
num.pop(0)
break
elif num[0] < max(num):
m = len(num)-1
num.append(num[0])
num.pop(0)
케이스를 나눠서 분기대로 처리해주면 끝나지만 while 문장에서 반복조건을 c(숫자의 개수)만큼만 반복하라고 한 실수가 있어 시간을 잡았다.
생각을 조금만 해보면.. c보다 숫자는 더 움직이는데 말이지.
여러 값을 입력받을 때 map구문이 여기저기 잘 쓰이는 중이다.