結果

問題 No.2453 Seat Allocation
ユーザー lloyz
提出日時 2023-09-04 01:15:47
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 509 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 102,936 KB
最終ジャッジ日時 2024-06-22 01:21:09
合計ジャッジ時間 4,273 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush
from math import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

lcm_ = 1
for i in range(m):
    lcm_ = lcm(lcm_, B[i])
H = []
for i in range(n):
    heappush(H, (-A[i] * (lcm_ // B[0]), i, 0))
for _ in range(m):
    _, ans, idx = heappop(H)
    print(ans + 1)
    idx += 1
    if idx == m:
        continue
    heappush(H, (-A[ans] * (lcm_ // B[idx]), ans, idx))
0