We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0ddbb21 commit da61eeeCopy full SHA for da61eee
1 file changed
이티예원/1966_프린터큐.py
@@ -0,0 +1,41 @@
1
+import sys
2
+
3
+#테스트 케이스 개수
4
+total = int(input())
5
+arr = []
6
7
+for a in range(total):
8
9
+ #문서의 개수 n, 궁금한 문서의 인덱스m
10
+ n, m = map(int, input().split())
11
12
+ #문서의 인덱스와 중요도를 묶은 리스트
13
+ arr = list(enumerate(list(map(int,input().split()))))
14
15
+ #순서를 알고싶은 문서의 인덱스와 중요도를 묶은 리스트
16
+ printer = arr[m]
17
18
+ #count) 해당 문서가 인쇄된 순서를 저장
19
+ count = 0
20
21
+ while len(arr):
22
23
+ #big) 배열의 가장 높은 우선순위
24
+ big = max(i[1] for i in arr)
25
26
+ #제일 앞에 있는 문서의 우선순위가 가장 높다면
27
+ if arr[0][1] == big:
28
+ #해당 문서를 pop()
29
+ nowIdx = arr.pop(0)
30
+ count += 1
31
32
+ if nowIdx == printer:
33
+ print(count)
34
+ break
35
36
+ #제일 앞에 있는 문서의 우선순위가 가장 높지 않다면
37
+ else:
38
+ #제일 앞에서 빼고
39
40
+ #제일 마지막에 넣어준다
41
+ arr.append(nowIdx)
0 commit comments