結果

問題 No.9 モンスターのレベル上げ
ユーザー DialBird
提出日時 2019-07-25 16:12:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 3,043 ms / 5,000 ms
コード長 614 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-07-02 06:10:11
合計ジャッジ時間 23,360 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heapreplace

def main():
    """ main """
    N = int(input())
    FRIENDS = list(map(lambda x: (int(x), 0), input().split()))
    ENEMIES = list(map(lambda x: int(x)//2, input().split()))

    max_value = float('inf')
    # # 的の順番ごとに一つ一つ確認していく
    for n in range(N):
        friends = FRIENDS[:]
        heapify(friends)
        for enemy in ENEMIES[n:] + ENEMIES[:n]:
            lv, cnt = friends[0]
            heapreplace(friends, (lv+enemy, cnt+1))
        max_value = min(max_value, max(cnt for lv, cnt in friends))

    print(max_value)

main()
0