結果

問題 No.9 モンスターのレベル上げ
ユーザー tnodino
提出日時 2022-05-26 18:13:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,131 ms / 5,000 ms
コード長 510 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 96,332 KB
最終ジャッジ日時 2024-09-20 15:04:18
合計ジャッジ時間 20,757 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy
from heapq import heappop,heappush
def f(x):
    heap = deepcopy(H)
    ret = 0
    for i in range(N):
        level,cnt = heappop(heap)
        level += B[(x+i)%N]
        cnt += 1
        ret = max(ret, cnt)
        heappush(heap, (level, cnt))
    return ret

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
H = []
for i in range(N):
    heappush(H, (A[i], 0))
    B[i] //= 2
ans = 1<<32
for i in range(N):
    ans = min(ans, f(i))
print(ans)
0