complete 1966.py
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
from collections import deque
|
||||
|
||||
|
||||
def case(N, M, I):
|
||||
q_id = deque(range(N))
|
||||
q_priority = deque(I)
|
||||
|
||||
q_m_p = q_priority[M]
|
||||
|
||||
q_id
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
T = int(input())
|
||||
for _ in range(T):
|
||||
print(case(*map(int, input().split()), list(map(int, input().split()))))
|
||||
24
zeta_python/completed/1966.py
Normal file
24
zeta_python/completed/1966.py
Normal 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()))))
|
||||
Reference in New Issue
Block a user