結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
![]() |
提出日時 | 2016-05-27 20:47:37 |
言語 | Python3 (3.10.1 + numpy 1.22.3 + scipy 1.8.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,149 bytes |
コンパイル時間 | 65 ms |
使用メモリ | 8,988 KB |
最終ジャッジ日時 | 2022-11-30 21:07:02 |
合計ジャッジ時間 | 52,065 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 22 ms
8,380 KB |
testcase_01 | AC | 23 ms
8,236 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 3,971 ms
8,848 KB |
testcase_04 | AC | 2,167 ms
8,692 KB |
testcase_05 | AC | 1,477 ms
8,696 KB |
testcase_06 | AC | 519 ms
8,408 KB |
testcase_07 | AC | 32 ms
8,284 KB |
testcase_08 | AC | 679 ms
8,692 KB |
testcase_09 | TLE | - |
testcase_10 | AC | 23 ms
8,388 KB |
testcase_11 | AC | 4,875 ms
8,804 KB |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | AC | 4,621 ms
8,988 KB |
testcase_16 | AC | 103 ms
8,284 KB |
testcase_17 | AC | 2,937 ms
8,756 KB |
testcase_18 | AC | 2,477 ms
8,760 KB |
testcase_19 | AC | 72 ms
8,220 KB |
ソースコード
#!/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()