結果

問題 No.2453 Seat Allocation
ユーザー miho-4
提出日時 2023-09-01 22:36:06
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 601 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 82,284 KB
実行使用メモリ 182,832 KB
最終ジャッジ日時 2024-06-11 17:52:35
合計ジャッジ時間 15,876 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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**5+n+1)):
  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])
0