結果
| 問題 | No.2453 Seat Allocation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-04 01:15:47 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 509 bytes |
| 記録 | |
| コンパイル時間 | 231 ms |
| コンパイル使用メモリ | 96,108 KB |
| 実行使用メモリ | 111,104 KB |
| 最終ジャッジ日時 | 2026-07-26 15:54:40 |
| 合計ジャッジ時間 | 4,670 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 20 |
ソースコード
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))