結果

問題 No.2453 Seat Allocation
ユーザー ntudantuda
提出日時 2023-09-09 14:04:30
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 679 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 164,828 KB
最終ジャッジ日時 2023-09-09 14:05:04
合計ジャッジ時間 34,058 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 213 ms
88,864 KB
testcase_01 AC 213 ms
88,736 KB
testcase_02 AC 209 ms
88,948 KB
testcase_03 AC 209 ms
88,992 KB
testcase_04 AC 221 ms
90,912 KB
testcase_05 AC 1,839 ms
157,172 KB
testcase_06 AC 1,225 ms
110,800 KB
testcase_07 AC 1,120 ms
131,020 KB
testcase_08 AC 1,006 ms
105,976 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 1,206 ms
106,500 KB
testcase_13 AC 1,347 ms
110,964 KB
testcase_14 AC 861 ms
106,848 KB
testcase_15 AC 1,771 ms
128,640 KB
testcase_16 AC 1,657 ms
118,224 KB
testcase_17 AC 233 ms
91,624 KB
testcase_18 AC 1,865 ms
141,852 KB
testcase_19 AC 1,997 ms
152,320 KB
testcase_20 AC 1,217 ms
120,676 KB
testcase_21 AC 1,322 ms
125,684 KB
testcase_22 AC 1,639 ms
133,892 KB
testcase_23 AC 208 ms
88,812 KB
testcase_24 AC 210 ms
88,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

'''
Yuki 2453
Seat Allocation

Ai/Bj (i = 1..N, j = 1..M)
を降り順にソートしたときのk番目のiを答える。
Challengeでfloatの割り算を着かれたのでDecimalにしてみる。
'''
from heapq import *
from decimal import Decimal

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
X = [1] * N  # それぞれの政党、次何番目か
q = []

for i, a in enumerate(A):
    b = Decimal(str(B[0]))
    heappush(q, (b / Decimal(str(a)), i))
for i in range(M):
    _, p = heappop(q)
    print(p + 1)
    if X[p] < M:
        heappush(q, (Decimal(str(B[X[p]])) / Decimal(str(A[p])), p))
        X[p] += 1

0