結果
| 問題 | 
                            No.2453 Seat Allocation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-09-04 01:16:03 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 509 bytes | 
| コンパイル時間 | 194 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 33,984 KB | 
| 最終ジャッジ日時 | 2024-06-22 01:21:23 | 
| 合計ジャッジ時間 | 4,188 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 2 TLE * 1 -- * 19 | 
ソースコード
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))