結果
| 問題 | No.2453 Seat Allocation |
| コンテスト | |
| ユーザー |
ikoma
|
| 提出日時 | 2023-09-01 23:54:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 663 bytes |
| 記録 | |
| コンパイル時間 | 413 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 299,048 KB |
| 最終ジャッジ日時 | 2025-01-03 13:28:03 |
| 合計ジャッジ時間 | 28,568 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 TLE * 6 |
ソースコード
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<<60
f = lambda a,b,i: (((a*offset//b)), 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][0]>pi[0] or heap[0][0]==pi[0] and heap[0][1]>pi[1]:break
heappush(heap, pi)
pi2 = heappop(heap)
ans = []
while heap:
p,i = heappop(heap)
# i = pi & ((1<<20)-1)
i = M-i
ans.append(i+1)
ans = reversed(ans)
print(*ans,sep="\n")
ikoma