結果

問題 No.2453 Seat Allocation
ユーザー chineristACchineristAC
提出日時 2023-09-01 23:47:22
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 896 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 106,464 KB
最終ジャッジ日時 2023-09-01 23:47:33
合計ジャッジ時間 9,545 ms
ジャッジサーバーID
(参考情報)
judge15 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
74,512 KB
testcase_01 AC 105 ms
75,028 KB
testcase_02 AC 107 ms
75,000 KB
testcase_03 RE -
testcase_04 AC 117 ms
78,900 KB
testcase_05 AC 486 ms
105,244 KB
testcase_06 AC 251 ms
95,844 KB
testcase_07 AC 267 ms
94,480 KB
testcase_08 AC 223 ms
84,032 KB
testcase_09 AC 610 ms
106,464 KB
testcase_10 AC 601 ms
105,604 KB
testcase_11 AC 576 ms
106,052 KB
testcase_12 AC 286 ms
95,504 KB
testcase_13 AC 323 ms
95,484 KB
testcase_14 AC 240 ms
95,664 KB
testcase_15 AC 379 ms
95,384 KB
testcase_16 AC 375 ms
95,120 KB
testcase_17 AC 115 ms
79,148 KB
testcase_18 AC 458 ms
103,120 KB
testcase_19 AC 509 ms
103,156 KB
testcase_20 AC 333 ms
90,476 KB
testcase_21 AC 360 ms
95,424 KB
testcase_22 AC 429 ms
103,020 KB
権限があれば一括ダウンロードができます

ソースコード

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