結果

問題 No.9 モンスターのレベル上げ
ユーザー DialBirdDialBird
提出日時 2019-07-25 16:24:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,133 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 8,660 KB
最終ジャッジ日時 2023-09-15 00:02:10
合計ジャッジ時間 17,669 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,976 KB
testcase_01 AC 15 ms
7,984 KB
testcase_02 AC 1,626 ms
8,652 KB
testcase_03 AC 1,246 ms
8,484 KB
testcase_04 AC 677 ms
8,340 KB
testcase_05 AC 450 ms
8,356 KB
testcase_06 AC 168 ms
8,048 KB
testcase_07 AC 17 ms
8,032 KB
testcase_08 AC 214 ms
8,328 KB
testcase_09 AC 1,551 ms
8,568 KB
testcase_10 AC 15 ms
7,972 KB
testcase_11 AC 1,452 ms
8,432 KB
testcase_12 AC 2,133 ms
8,440 KB
testcase_13 AC 1,386 ms
8,460 KB
testcase_14 AC 1,566 ms
8,660 KB
testcase_15 AC 1,413 ms
8,552 KB
testcase_16 AC 42 ms
8,052 KB
testcase_17 AC 917 ms
8,532 KB
testcase_18 AC 796 ms
8,412 KB
testcase_19 AC 30 ms
7,980 KB
権限があれば一括ダウンロードができます

ソースコード

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()))

    heapify(FRIENDS)
    max_value = float('inf')
    for n in range(N):
        friends = 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