結果
| 問題 | No.2453 Seat Allocation | 
| コンテスト | |
| ユーザー |  ikoma | 
| 提出日時 | 2023-09-01 23:49:04 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 616 bytes | 
| コンパイル時間 | 604 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 163,988 KB | 
| 最終ジャッジ日時 | 2025-01-03 13:10:40 | 
| 合計ジャッジ時間 | 45,640 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 5 WA * 3 TLE * 14 | 
ソースコード
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]
offset = 1<<40
f = lambda a,b,i: (((a*offset//b)<<20) +M-i)
heap = [ f(a,b,i) for b in B]
heapify(heap)
for a,i in Ai[1:]:
    for b in B:
        pi = f(a,b,i)
        if heap[0]==pi:break
        heappush(heap, pi)
        pi2 = heappop(heap)
ans = []
while heap:
    pi = heappop(heap)
    i = pi & ((1<<20)-1)
    i = M-i
    ans.append(i+1)
ans = reversed(ans)
print(*ans,sep="\n")
            
            
            
        