結果
問題 | No.2453 Seat Allocation |
ユーザー |
|
提出日時 | 2023-09-01 22:35:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 597 bytes |
コンパイル時間 | 736 ms |
コンパイル使用メモリ | 82,656 KB |
実行使用メモリ | 577,768 KB |
最終ジャッジ日時 | 2025-01-03 09:58:12 |
合計ジャッジ時間 | 50,998 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 1 TLE * 15 MLE * 1 |
ソースコード
import heapq n,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) L=[(A[i],i) for i in range(n)] L.sort(reverse=1,key=lambda x:x[0]) H=[(-L[0][0]/B[0],0,0)] S=set() ans=[] for _ in range(min(m*n,10**6)): x,i,j=heapq.heappop(H) ans.append( (x,L[i][1]+1) ) if i+1<n and (i+1,j) not in S: S.add((i+1,j)) heapq.heappush(H,(-L[i+1][0]/B[j],i+1,j)) if j+1<m and (i,j+1) not in S: S.add((i,j+1)) heapq.heappush(H,(-L[i][0]/B[j+1],i,j+1)) ans.sort(key=lambda x:x[1]) ans.sort(key=lambda x:x[0]) for i in range(m): print(ans[i][1])