結果

問題 No.2453 Seat Allocation
ユーザー noriocnorioc
提出日時 2023-09-06 01:45:04
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 528 bytes
コンパイル時間 660 ms
コンパイル使用メモリ 86,592 KB
実行使用メモリ 141,352 KB
最終ジャッジ日時 2023-09-06 01:45:15
合計ジャッジ時間 10,148 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
89,944 KB
testcase_01 AC 231 ms
89,496 KB
testcase_02 AC 238 ms
89,508 KB
testcase_03 AC 241 ms
89,380 KB
testcase_04 AC 238 ms
89,316 KB
testcase_05 AC 1,716 ms
139,372 KB
testcase_06 AC 776 ms
105,848 KB
testcase_07 AC 677 ms
112,804 KB
testcase_08 AC 557 ms
95,164 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
from fractions import Fraction

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

B.sort()

q = []  # (score, a-index, b-index)
for i, a in enumerate(A):
    heappush(q, (-Fraction(a, B[0]), i, 0))

ans = []
for _ in range(M):
    _, a_index, b_index = heappop(q)
    ans.append(a_index + 1)
    if b_index+1 < M:
        frac = -Fraction(A[a_index], B[b_index+1])
        heappush(q, (frac, a_index, b_index+1))

print(*ans, sep='\n')
0