結果

問題 No.9 モンスターのレベル上げ
ユーザー nisizawa
提出日時 2017-12-19 13:12:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 4,150 ms / 5,000 ms
コード長 574 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-06-24 00:22:02
合計ジャッジ時間 16,934 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n = int(input())
a_ls = [int(a) for a in input().split()]
b_ls = [int(b) for b in input().split()]

hq_o = [(a, 0) for a in a_ls]
heapq.heapify(hq_o)

db_ls = b_ls + b_ls

ct_max_min = n
for i in range(n):
    hq = hq_o[:]
    
    ct_max = 0
    for j in range(n):
        lv, ct = hq[0]
        lv += db_ls[i + j] // 2
        ct += 1
        heapq.heapreplace(hq, (lv, ct))
        if ct > ct_max:
            ct_max = ct
        
        if ct_max >= ct_max_min:
            break

    if ct_max < ct_max_min:
        ct_max_min = ct_max

print(ct_max_min)
0