complete 1966.py

This commit is contained in:
2024-04-15 23:17:15 +09:00
parent 38397f754b
commit 35f80a6125
2 changed files with 24 additions and 16 deletions

View File

@@ -0,0 +1,24 @@
import sys
input = sys.stdin.readline
# 너무 개같이 짬 PriorityQueue로 구현할 수 있지 않을까?
def case(N, M, I):
D = [(v, i) for i, v in enumerate(I)]
cnt = 0
while D:
most = max(D)[0]
w, ind = D.pop(0)
if w == most:
cnt += 1
if ind == M: # if target
return cnt
else:
D.append((w, ind))
if __name__ == "__main__":
T = int(input())
for _ in range(T):
print(case(*map(int, input().split()), list(map(int, input().split()))))