結果
問題 | No.2453 Seat Allocation |
ユーザー | norioc |
提出日時 | 2023-09-06 01:55:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 872 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 86,844 KB |
実行使用メモリ | 131,440 KB |
最終ジャッジ日時 | 2023-09-06 01:56:13 |
合計ジャッジ時間 | 20,618 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
71,136 KB |
testcase_01 | AC | 77 ms
70,852 KB |
testcase_02 | AC | 75 ms
71,136 KB |
testcase_03 | AC | 77 ms
71,004 KB |
testcase_04 | AC | 79 ms
71,148 KB |
testcase_05 | AC | 1,084 ms
128,496 KB |
testcase_06 | AC | 380 ms
91,220 KB |
testcase_07 | AC | 343 ms
97,748 KB |
testcase_08 | AC | 256 ms
80,060 KB |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | AC | 332 ms
90,632 KB |
testcase_13 | AC | 497 ms
91,320 KB |
testcase_14 | AC | 191 ms
90,988 KB |
testcase_15 | AC | 891 ms
97,088 KB |
testcase_16 | AC | 543 ms
90,980 KB |
testcase_17 | AC | 77 ms
71,108 KB |
testcase_18 | AC | 1,529 ms
117,700 KB |
testcase_19 | AC | 1,721 ms
125,020 KB |
testcase_20 | AC | 763 ms
94,812 KB |
testcase_21 | AC | 992 ms
99,156 KB |
testcase_22 | AC | 1,411 ms
114,404 KB |
testcase_23 | AC | 77 ms
71,208 KB |
testcase_24 | AC | 75 ms
71,080 KB |
ソースコード
from heapq import heappush, heappop class Frac: def __init__(self, num, den): self.num = -num self.den = den def __eq__(self, other): a = self.num * other.den b = other.num * self.den return a == b def __lt__(self, other): a = self.num * other.den b = other.num * self.den return a < b N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) B.sort() q = [] # (score, a-index, b-index) for i, a in enumerate(A): heappush(q, (Frac(a, B[0]), i, 0)) ans = [] for _ in range(M): x, a_index, b_index = heappop(q) # print(f'{x.num}/{x.den} {a_index=} {b_index=}') ans.append(a_index + 1) if b_index+1 < M: frac = Frac(A[a_index], B[b_index+1]) heappush(q, (frac, a_index, b_index+1)) print(*ans, sep='\n')