結果

問題 No.2453 Seat Allocation
ユーザー lloyzlloyz
提出日時 2023-09-04 01:22:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 413 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 111,256 KB
最終ジャッジ日時 2023-09-07 15:38:49
合計ジャッジ時間 7,191 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,360 KB
testcase_01 AC 74 ms
71,268 KB
testcase_02 AC 74 ms
71,704 KB
testcase_03 AC 74 ms
71,368 KB
testcase_04 AC 75 ms
71,396 KB
testcase_05 AC 291 ms
111,256 KB
testcase_06 AC 172 ms
91,316 KB
testcase_07 AC 159 ms
96,268 KB
testcase_08 AC 152 ms
80,476 KB
testcase_09 AC 413 ms
103,544 KB
testcase_10 AC 401 ms
104,424 KB
testcase_11 AC 412 ms
104,516 KB
testcase_12 AC 248 ms
91,600 KB
testcase_13 AC 262 ms
92,168 KB
testcase_14 AC 144 ms
91,380 KB
testcase_15 AC 303 ms
91,380 KB
testcase_16 AC 306 ms
91,104 KB
testcase_17 AC 77 ms
71,476 KB
testcase_18 AC 311 ms
97,424 KB
testcase_19 AC 378 ms
103,120 KB
testcase_20 AC 227 ms
85,540 KB
testcase_21 AC 233 ms
86,280 KB
testcase_22 AC 297 ms
94,188 KB
testcase_23 AC 75 ms
71,412 KB
testcase_24 AC 76 ms
71,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush

class T(object):
    def __init__(self, bunsi, bunbo, idx):
        self.bunsi = bunsi
        self.bunbo = bunbo
        self.idx = idx
    
    def __lt__(self, other):
        if other.bunbo * self.bunsi == self.bunbo * other.bunsi:
            return other.idx > self.idx
        else:
            return other.bunbo * self.bunsi > self.bunbo * other.bunsi

n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

H = []
for i in range(n):
    heappush(H, T(A[i], B[0], i))
C = [0 for _ in range(n)]
for _ in range(m):
    t = heappop(H)
    idx = t.idx
    print(idx + 1)
    C[idx] += 1
    if C[idx] == m:
        continue
    heappush(H, T(A[idx], B[C[idx]], idx))
0