結果

問題 No.2453 Seat Allocation
ユーザー mymelochan
提出日時 2023-09-02 17:42:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 434 ms / 2,000 ms
コード長 1,162 bytes
コンパイル時間 1,449 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 112,604 KB
最終ジャッジ日時 2025-06-20 01:48:52
合計ジャッジ時間 7,549 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#############################################################

import sys
sys.setrecursionlimit(10**7)

from heapq import heappop,heappush
from collections import deque,defaultdict,Counter
from bisect import bisect_left, bisect_right
from itertools import product,combinations,permutations

ipt = sys.stdin.readline

def iin():
    return int(ipt())
def lmin():
    return list(map(int,ipt().split()))

MOD = 998244353
L = 10**15

class YS(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 = lmin()
A = lmin()
B = lmin()

cnt = [1]*N
hq = []
for i,a in enumerate(A):
    heappush(hq,YS(a,B[0],i))

ans = []
while True:
    ys = heappop(hq)
    idx = ys.idx
    ans.append(idx+1)
    if len(ans) == M:
        break
    heappush(hq,YS(A[idx],B[cnt[idx]],idx))
    cnt[idx] += 1


for a in ans:
    print(a)
0