結果

問題 No.2453 Seat Allocation
ユーザー ntudantuda
提出日時 2023-09-02 10:39:45
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 491 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 108,436 KB
最終ジャッジ日時 2023-09-02 11:15:25
合計ジャッジ時間 6,811 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,284 KB
testcase_01 AC 75 ms
71,296 KB
testcase_02 AC 77 ms
71,288 KB
testcase_03 AC 76 ms
71,136 KB
testcase_04 AC 77 ms
71,280 KB
testcase_05 AC 290 ms
108,436 KB
testcase_06 AC 158 ms
92,972 KB
testcase_07 AC 151 ms
92,184 KB
testcase_08 AC 132 ms
79,104 KB
testcase_09 AC 357 ms
97,404 KB
testcase_10 AC 355 ms
97,852 KB
testcase_11 AC 358 ms
97,676 KB
testcase_12 AC 228 ms
92,672 KB
testcase_13 AC 237 ms
92,800 KB
testcase_14 AC 141 ms
92,420 KB
testcase_15 AC 276 ms
93,124 KB
testcase_16 AC 274 ms
92,324 KB
testcase_17 AC 76 ms
71,092 KB
testcase_18 AC 294 ms
93,736 KB
testcase_19 AC 327 ms
97,016 KB
testcase_20 AC 200 ms
86,192 KB
testcase_21 AC 219 ms
87,368 KB
testcase_22 AC 284 ms
92,136 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

'''
Yuki 2453
Seat Allocation

Ai/Bj (i = 1..N, j = 1..M)
を降り順にソートしたときのk番目のiを答える。
'''
from heapq import *

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split())) + [1]

X = [1] * N  # それぞれの政党、次何番目か
q = []
for i, a in enumerate(A):
    heappush(q, (-a / B[0], i))
for k in range(M):
    _, p = heappop(q)
    print(p + 1)
    heappush(q, (-A[p] / B[X[p]], p))
    X[p] += 1
0