結果

問題 No.2453 Seat Allocation
ユーザー sotanishysotanishy
提出日時 2023-09-01 21:46:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,410 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 134,396 KB
最終ジャッジ日時 2023-09-07 15:34:52
合計ジャッジ時間 18,830 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 223 ms
89,168 KB
testcase_01 AC 226 ms
89,308 KB
testcase_02 AC 223 ms
89,304 KB
testcase_03 AC 220 ms
89,300 KB
testcase_04 AC 224 ms
88,988 KB
testcase_05 AC 855 ms
131,588 KB
testcase_06 AC 518 ms
104,608 KB
testcase_07 AC 431 ms
113,204 KB
testcase_08 AC 437 ms
96,544 KB
testcase_09 AC 1,410 ms
134,136 KB
testcase_10 AC 1,341 ms
134,396 KB
testcase_11 AC 1,374 ms
133,028 KB
testcase_12 AC 739 ms
106,152 KB
testcase_13 AC 708 ms
107,660 KB
testcase_14 AC 363 ms
105,096 KB
testcase_15 AC 805 ms
108,116 KB
testcase_16 AC 778 ms
106,364 KB
testcase_17 AC 225 ms
89,304 KB
testcase_18 AC 1,073 ms
119,892 KB
testcase_19 AC 1,237 ms
125,000 KB
testcase_20 AC 672 ms
105,928 KB
testcase_21 AC 767 ms
108,412 KB
testcase_22 AC 1,031 ms
118,176 KB
testcase_23 AC 223 ms
88,992 KB
testcase_24 AC 225 ms
89,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
heap = []
cnt = [0]*N
for i in range(N):
    heappush(heap, (-Fraction(A[i], B[0]), i))
ans = []
for _ in range(M):
    v, i = heappop(heap)
    ans.append(i+1)
    cnt[i] += 1
    if cnt[i] < M:
        heappush(heap, (-Fraction(A[i], B[cnt[i]]), i))
print(*ans, sep="\n")
0