結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-04 01:22:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 412 ms / 2,000 ms |
| コード長 | 760 bytes |
| コンパイル時間 | 368 ms |
| コンパイル使用メモリ | 82,772 KB |
| 実行使用メモリ | 110,608 KB |
| 最終ジャッジ日時 | 2025-06-20 01:49:09 |
| 合計ジャッジ時間 | 6,510 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
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))