[python]白駿1966号:プリンタキュー
4534 ワード
https://www.acmicpc.net/problem/1966
に答える
印刷ドキュメントインデックスを含む印刷リストを作成し、すべてのドキュメントが印刷されるまで繰り返します.
現在のドキュメントの重要度がリストの重要度以上の場合は、重要度を-1に変更しながらインデックスを印刷に追加します.
出力されたインデックスがm
である場合、印刷された文書の長さ+1が出力され、ループが終了する.
コード#コード# import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = map(int,input().split())
importances = list(map(int, input().split()))
printed = []
i = 0
lenth = len(importances)
while m not in printed:
imp = importances[i]
if imp >= max(importances):
if i==m:
print(len(printed)+1)
break
printed.append(i)
importances[i] = -1
i = (i + 1) % lenth
Reference
この問題について([python]白駿1966号:プリンタキュー), 我々は、より多くの情報をここで見つけました
https://velog.io/@joniekwon/Python-백준-1966번-프린터-큐
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = map(int,input().split())
importances = list(map(int, input().split()))
printed = []
i = 0
lenth = len(importances)
while m not in printed:
imp = importances[i]
if imp >= max(importances):
if i==m:
print(len(printed)+1)
break
printed.append(i)
importances[i] = -1
i = (i + 1) % lenth
Reference
この問題について([python]白駿1966号:プリンタキュー), 我々は、より多くの情報をここで見つけました https://velog.io/@joniekwon/Python-백준-1966번-프린터-큐テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol