結果
問題 | No.2453 Seat Allocation |
ユーザー |
![]() |
提出日時 | 2024-12-22 06:53:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,564 ms / 2,000 ms |
コード長 | 549 bytes |
コンパイル時間 | 1,496 ms |
コンパイル使用メモリ | 81,832 KB |
実行使用メモリ | 120,496 KB |
最終ジャッジ日時 | 2025-06-20 02:19:08 |
合計ジャッジ時間 | 18,221 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
from fractions import Fraction from heapq import heappush, heappop N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) def IDX(i, j): return i*(M+1)+j def IDXR(n): return n//(M+1), n%(M+1) que = [] for i in range(N): heappush(que, (-Fraction(A[i], B[0]), IDX(i, 0))) for _ in range(M): f, n = heappop(que) i, j = IDXR(n) f = -f print(i+1) if j+1 < M: heappush(que, (-Fraction(A[i], B[j+1]), IDX(i, j+1))) else: heappush(que, (0, IDX(i, M)))