https://www.acmicpc.net/problem/1966
import sys
n = int(sys.stdin.readline().split()[0])
for i in range(n):
doc_count, target = [int(x) for x in sys.stdin.readline().split()]
list = [int(x) for x in sys.stdin.readline().split()]
new_list = [{'index': index, 'value': value} for index, value in enumerate(list)]
rlt = []
while new_list:
if new_list[0]['value'] == max([x['value'] for x in new_list]):
rlt.append(new_list.pop(0))
else:
new_list.append(new_list.pop(0))
count = 0
for r in rlt:
count += 1
if r['index'] == target:
break
print(count)
문제를 잘 읽어보고 구현하면 되는데,
자꾸 잘못 이해해서 시간만 썼따리
ㅠㅠㅠ
test_case = int(input())
for _ in range(test_case):
n, m = list(map(int, input().split(' ')))
queue = list(map(int, input().split(' ')))
queue = [(i, idx) for idx, i in enumerate(queue)]
count = 0
while True:
if queue[0][0] == max(queue, key=lambda x: x[0])[0]:
count += 1
if queue[0][1] == m:
print(count)
break
else:
queue.pop(0)
else:
queue.append(queue.pop(0))