結果

問題 No.2453 Seat Allocation
ユーザー Kude
提出日時 2023-09-01 21:47:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,408 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 121,512 KB
最終ジャッジ日時 2025-06-20 01:44:01
合計ジャッジ時間 16,809 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappushpop, heapify
from fractions import Fraction
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(1)
q = [(-Fraction(a[i], b[0]), i) for i in range(n)]
now = [0] * n
heapify(q)
for _ in range(m):
    _, i = q[0]
    print(i + 1)
    now[i] += 1
    heappushpop(q, (-Fraction(a[i], b[now[i]]), i))
0