結果

問題 No.2453 Seat Allocation
ユーザー fiblonariafiblonaria
提出日時 2023-09-05 14:53:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,461 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 109,336 KB
最終ジャッジ日時 2023-09-05 14:53:39
合計ジャッジ時間 15,972 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,324 KB
testcase_01 AC 75 ms
71,532 KB
testcase_02 AC 76 ms
71,368 KB
testcase_03 AC 81 ms
71,584 KB
testcase_04 AC 77 ms
71,324 KB
testcase_05 AC 970 ms
108,544 KB
testcase_06 AC 311 ms
93,436 KB
testcase_07 AC 461 ms
92,588 KB
testcase_08 AC 271 ms
80,628 KB
testcase_09 AC 1,270 ms
109,336 KB
testcase_10 AC 1,283 ms
108,800 KB
testcase_11 AC 1,328 ms
108,972 KB
testcase_12 AC 295 ms
93,272 KB
testcase_13 AC 403 ms
93,596 KB
testcase_14 AC 195 ms
92,804 KB
testcase_15 AC 514 ms
93,740 KB
testcase_16 AC 376 ms
92,872 KB
testcase_17 AC 79 ms
71,184 KB
testcase_18 AC 860 ms
95,688 KB
testcase_19 AC 1,052 ms
103,996 KB
testcase_20 AC 495 ms
86,988 KB
testcase_21 AC 541 ms
87,744 KB
testcase_22 AC 804 ms
93,784 KB
testcase_23 WA -
testcase_24 AC 75 ms
71,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class heap:
    #comp:比較関数 小さいものから順に取り出す
    def __init__(s, comp = lambda x:x):
        s.comp = comp
        s.values = []
    #index と 子供たちの位置関係を調整
    def adjust(s, index):
        next = None
        cur = s.comp(s.values[index])
        for i in range(index * 2 + 1, min(index * 2 + 3, len(s.values))):
            if cur > s.comp(s.values[i]):
                next = i
                cur = s.comp(s.values[i])
        if next != None:
            s.values[index], s.values[next] = s.values[next], s.values[index]
            return next
        else:
            return None
    def push(s, value):
        s.values.append(value)
        index = (len(s.values) - 2) // 2
        while index >= 0:
            s.adjust(index)
            index = (index - 1) // 2
    def pop(s):
        if len(s.values) == 0:
            return None
        if len(s.values) == 1:
            return s.values.pop()
        ret = s.values[0]
        s.values[0] = s.values.pop()
        index = 0
        while index != None:
            index = s.adjust(index)
        return ret
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split())) + [1]
number = [0 for i in range(N)]
H = heap()
for i in range(N):
	H.push((-(A[i] / B[0]), i))
for i in range(M):
	cur = H.pop()
	number[cur[1]] += 1
	print(cur[1] + 1)
	H.push((-(A[cur[1]] / B[number[cur[1]]]), cur[1]))
0