結果

問題 No.2453 Seat Allocation
コンテスト
ユーザー norioc
提出日時 2023-09-06 01:45:04
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 528 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 260 ms
コンパイル使用メモリ 95,604 KB
実行使用メモリ 151,112 KB
最終ジャッジ日時 2026-07-28 07:09:25
合計ジャッジ時間 25,715 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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