結果

問題 No.9 モンスターのレベル上げ
ユーザー DialBirdDialBird
提出日時 2019-07-25 16:04:29
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 2,496 ms / 5,000 ms
コード長 666 bytes
コンパイル時間 66 ms
使用メモリ 8,272 KB
最終ジャッジ日時 2023-02-02 18:32:44
合計ジャッジ時間 20,658 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 16 ms
7,768 KB
testcase_01 AC 17 ms
7,704 KB
testcase_02 AC 1,998 ms
8,160 KB
testcase_03 AC 1,574 ms
8,080 KB
testcase_04 AC 834 ms
8,080 KB
testcase_05 AC 560 ms
7,860 KB
testcase_06 AC 205 ms
7,752 KB
testcase_07 AC 20 ms
7,728 KB
testcase_08 AC 269 ms
7,976 KB
testcase_09 AC 1,932 ms
8,128 KB
testcase_10 AC 17 ms
7,708 KB
testcase_11 AC 1,786 ms
8,272 KB
testcase_12 AC 2,496 ms
8,036 KB
testcase_13 AC 1,691 ms
8,152 KB
testcase_14 AC 1,932 ms
8,164 KB
testcase_15 AC 1,792 ms
8,024 KB
testcase_16 AC 47 ms
7,752 KB
testcase_17 AC 1,146 ms
8,104 KB
testcase_18 AC 957 ms
8,040 KB
testcase_19 AC 34 ms
7,904 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