結果

問題 No.2453 Seat Allocation
ユーザー chineristAC
提出日時 2023-09-01 23:47:22
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 896 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 107,008 KB
最終ジャッジ日時 2025-01-03 13:06:15
合計ジャッジ時間 10,095 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 1 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random
from itertools import permutations
from collections import deque
from heapq import *

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N,M = mi()
A = li()
B = li()

A_val = [a for a in A]
A_val.sort()

def cond(x):
    res = 0
    lower = 0
    for b in B:
        while lower!=N and A_val[lower] < x * b:
            lower += 1
        res += N - lower
    return res >= M

ok = 0
ng = 10**9+1
for _ in range(60):
    mid = (ok+ng)/2
    if cond(mid):
        ok = mid
    else:
        ng = mid

select = []
idx = [0 for i in range(M)]
t = 10**18
pq = [(-A[i]*t/B[0],i) for i in range(N)]
heapify(pq)
while len(select) < M:
    val,i = heappop(pq)
    select.append((i,idx[i]))
    idx[i] += 1
    if idx[i] < M:
        val = -A[i]*t/B[idx[i]]
        heappush(pq,(val,i))


for i,j in select:
    print(i+1)






0