結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2023-09-09 14:04:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 679 bytes |
| コンパイル時間 | 416 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 149,140 KB |
| 最終ジャッジ日時 | 2024-06-27 07:00:20 |
| 合計ジャッジ時間 | 30,484 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 TLE * 4 |
ソースコード
'''
Yuki 2453
Seat Allocation
Ai/Bj (i = 1..N, j = 1..M)
を降り順にソートしたときのk番目のiを答える。
Challengeでfloatの割り算を着かれたのでDecimalにしてみる。
'''
from heapq import *
from decimal import Decimal
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
X = [1] * N # それぞれの政党、次何番目か
q = []
for i, a in enumerate(A):
b = Decimal(str(B[0]))
heappush(q, (b / Decimal(str(a)), i))
for i in range(M):
_, p = heappop(q)
print(p + 1)
if X[p] < M:
heappush(q, (Decimal(str(B[X[p]])) / Decimal(str(A[p])), p))
X[p] += 1
ntuda