結果

問題 No.2453 Seat Allocation
ユーザー miho-4miho-4
提出日時 2023-09-01 22:35:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 597 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 290,476 KB
最終ジャッジ日時 2023-09-01 22:35:07
合計ジャッジ時間 4,637 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,644 KB
testcase_01 AC 78 ms
71,288 KB
testcase_02 AC 79 ms
71,264 KB
testcase_03 AC 76 ms
71,432 KB
testcase_04 AC 98 ms
76,032 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

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**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])
0