結果
問題 | No.2453 Seat Allocation |
ユーザー | norioc |
提出日時 | 2023-09-06 02:02:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,538 ms / 2,000 ms |
コード長 | 851 bytes |
コンパイル時間 | 339 ms |
コンパイル使用メモリ | 87,148 KB |
実行使用メモリ | 129,864 KB |
最終ジャッジ日時 | 2023-09-07 15:39:28 |
合計ジャッジ時間 | 15,385 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
71,488 KB |
testcase_01 | AC | 75 ms
71,656 KB |
testcase_02 | AC | 74 ms
71,488 KB |
testcase_03 | AC | 74 ms
71,168 KB |
testcase_04 | AC | 74 ms
71,484 KB |
testcase_05 | AC | 943 ms
127,224 KB |
testcase_06 | AC | 308 ms
92,004 KB |
testcase_07 | AC | 321 ms
97,520 KB |
testcase_08 | AC | 215 ms
80,288 KB |
testcase_09 | AC | 1,538 ms
129,120 KB |
testcase_10 | AC | 1,448 ms
129,864 KB |
testcase_11 | AC | 1,431 ms
129,212 KB |
testcase_12 | AC | 287 ms
91,352 KB |
testcase_13 | AC | 459 ms
91,500 KB |
testcase_14 | AC | 178 ms
91,252 KB |
testcase_15 | AC | 632 ms
95,076 KB |
testcase_16 | AC | 430 ms
90,852 KB |
testcase_17 | AC | 75 ms
71,296 KB |
testcase_18 | AC | 1,068 ms
116,116 KB |
testcase_19 | AC | 1,242 ms
122,608 KB |
testcase_20 | AC | 535 ms
93,160 KB |
testcase_21 | AC | 684 ms
96,952 KB |
testcase_22 | AC | 974 ms
112,468 KB |
testcase_23 | AC | 74 ms
71,396 KB |
testcase_24 | AC | 74 ms
71,416 KB |
ソースコード
from heapq import heappush, heappop class Frac: def __init__(self, num, den, index): self.num = -num self.den = den self.index = index def __lt__(self, other): a = self.num * other.den b = other.num * self.den if a == b: return self.index < other.index 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, 0)) ans = [] for _ in range(M): x, b_index, _ = heappop(q) # print(f'{x.num}/{x.den} {a_index=} {b_index=}') ans.append(x.index + 1) if b_index+1 < M: frac = Frac(A[x.index], B[b_index+1], x.index) heappush(q, (frac, b_index+1, 0)) print(*ans, sep='\n')