結果

問題 No.2453 Seat Allocation
ユーザー miho-4miho-4
提出日時 2023-09-01 22:36:06
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 601 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 183,996 KB
最終ジャッジ日時 2023-09-02 11:13:27
合計ジャッジ時間 18,450 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,628 KB
testcase_01 AC 73 ms
71,408 KB
testcase_02 AC 71 ms
71,476 KB
testcase_03 AC 72 ms
71,604 KB
testcase_04 AC 90 ms
76,324 KB
testcase_05 AC 1,097 ms
174,920 KB
testcase_06 AC 347 ms
99,712 KB
testcase_07 AC 1,119 ms
180,644 KB
testcase_08 AC 605 ms
112,396 KB
testcase_09 AC 1,632 ms
172,308 KB
testcase_10 AC 1,616 ms
183,996 KB
testcase_11 AC 1,643 ms
174,356 KB
testcase_12 AC 527 ms
108,976 KB
testcase_13 AC 473 ms
104,144 KB
testcase_14 AC 574 ms
114,684 KB
testcase_15 AC 590 ms
101,856 KB
testcase_16 AC 573 ms
105,444 KB
testcase_17 AC 88 ms
76,416 KB
testcase_18 AC 1,143 ms
139,124 KB
testcase_19 AC 1,409 ms
161,904 KB
testcase_20 AC 958 ms
125,364 KB
testcase_21 AC 784 ms
112,368 KB
testcase_22 AC 999 ms
124,468 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

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