結果
| 問題 | No.9 モンスターのレベル上げ |
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-05-27 20:47:37 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 3,794 ms / 5,000 ms |
| コード長 | 1,149 bytes |
| 記録 | |
| コンパイル時間 | 470 ms |
| コンパイル使用メモリ | 20,952 KB |
| 実行使用メモリ | 15,484 KB |
| 最終ジャッジ日時 | 2026-04-13 05:42:55 |
| 合計ジャッジ時間 | 37,161 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#!/usr/bin/env python3
import array
import collections
import copy
import heapq
INF = 10 ** 9
State = collections.namedtuple("State", "level battles index")
def rotations(iterable, tuplify=True):
d = collections.deque(iterable)
n = len(d)
for _ in range(n):
d.rotate()
y = copy.copy(d)
yield tuple(y) if tuplify else y
def compute_min(friend_levels, enemy_levels):
fs = friend_levels
answer = INF
for es in rotations(enemy_levels, False):
pq = [State(f, 0, i) for i, f in enumerate(fs)]
heapq.heapify(pq)
while es:
state = heapq.heappop(pq)
e = es.popleft()
new_level = state.level + e // 2
new_battles = state.battles + 1
heapq.heappush(pq, State(new_level, new_battles, state.index))
answer = min(answer, max(s.battles for s in pq))
return answer
def main():
_ = input()
friend_levels = array.array("I", map(int, input().split()))
enemy_levels = array.array("I", map(int, input().split()))
print(compute_min(friend_levels, enemy_levels))
if __name__ == '__main__':
main()
はむ吉🐹