結果

問題 No.9 モンスターのレベル上げ
ユーザー ryusuke
提出日時 2022-02-05 17:07:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,751 ms / 5,000 ms
コード長 486 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 89,476 KB
最終ジャッジ日時 2024-06-11 13:37:09
合計ジャッジ時間 18,080 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = []
for start in range(n):
    q = []
    heapify(q)
    for i in range(n):
        heappush(q, (a[i], 0))
    
    for i in range(n):
        p, num = heappop(q)
        p += b[(start + i) % n] // 2
        heappush(q, (p, num + 1))

    ma = 0
    for i in range(n):
        ma = max(ma, heappop(q)[1])
    
    ans.append(ma)

print(min(ans))
0