結果

問題 No.9 モンスターのレベル上げ
ユーザー qib
提出日時 2023-03-20 00:07:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,119 ms / 5,000 ms
コード長 473 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 79,572 KB
最終ジャッジ日時 2024-09-18 13:55:11
合計ジャッジ時間 12,579 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

INF = 10 ** 5

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

ans = 1 << 60
for src in range(n):
  hp = []
  for i in range(n):
    heapq.heappush(hp, INF * a[i])

  for i in range(n):
    x = heapq.heappop(hp)
    l, c = x // INF, x % INF
    l += b[(i + src) % n] // 2
    c += 1
    heapq.heappush(hp, l * INF + c)

  cnt = 0
  for x in hp:
    c = x % INF
    cnt = max(cnt, c)

  ans = min(ans, cnt)

print(ans)
0