結果
| 問題 | No.2453 Seat Allocation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-04 01:16:03 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 509 bytes |
| 記録 | |
| コンパイル時間 | 323 ms |
| コンパイル使用メモリ | 20,956 KB |
| 実行使用メモリ | 247,012 KB |
| 最終ジャッジ日時 | 2026-03-06 07:06:16 |
| 合計ジャッジ時間 | 48,615 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 TLE * 15 |
ソースコード
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))