結果

問題 No.9 モンスターのレベル上げ
ユーザー DialBirdDialBird
提出日時 2019-07-25 16:04:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,249 ms / 5,000 ms
コード長 666 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 8,688 KB
最終ジャッジ日時 2023-09-14 23:58:27
合計ジャッジ時間 18,411 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,984 KB
testcase_01 AC 17 ms
8,052 KB
testcase_02 AC 1,787 ms
8,688 KB
testcase_03 AC 1,404 ms
8,536 KB
testcase_04 AC 751 ms
8,504 KB
testcase_05 AC 506 ms
8,012 KB
testcase_06 AC 184 ms
8,352 KB
testcase_07 AC 19 ms
8,088 KB
testcase_08 AC 238 ms
8,004 KB
testcase_09 AC 1,724 ms
8,632 KB
testcase_10 AC 16 ms
8,144 KB
testcase_11 AC 1,592 ms
8,548 KB
testcase_12 AC 2,249 ms
8,484 KB
testcase_13 AC 1,498 ms
8,604 KB
testcase_14 AC 1,723 ms
8,620 KB
testcase_15 AC 1,577 ms
8,328 KB
testcase_16 AC 43 ms
8,008 KB
testcase_17 AC 1,015 ms
8,612 KB
testcase_18 AC 852 ms
8,600 KB
testcase_19 AC 31 ms
8,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heapreplace

def main():
    """ main """
    N = int(input())
    FRIENDS = list(map(int, input().split()))
    ENEMIES = list(map(int, input().split()))

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

    print(max_value)

main()
0