結果

問題 No.2453 Seat Allocation
ユーザー ikoma
提出日時 2023-09-01 23:26:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 533 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 161,332 KB
最終ジャッジ日時 2025-01-03 12:30:25
合計ジャッジ時間 22,111 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 1 TLE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Ai = [(a,i) for i,a in enumerate(A)]
Ai.sort(reverse=True)
a,i = Ai[0]

heap = [(a/b, -i) for b in B]
heapify(heap)

for a,i in Ai[1:]:
    i=-i
    for b in B:
        p = a/b
        heappush(heap, (p, i))
        p2,i2 = heappop(heap)
        if (p,i)==(p2,i2):break

ans = []
while heap:
    _,i = heappop(heap)
    ans.append(-i+1)

ans = reversed(ans)
print(*ans,sep="\n")
0