結果

問題 No.9 モンスターのレベル上げ
ユーザー rpy3cpprpy3cpp
提出日時 2015-08-07 00:08:37
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 2,570 ms / 5,000 ms
コード長 491 bytes
コンパイル時間 58 ms
使用メモリ 8,256 KB
最終ジャッジ日時 2023-01-21 14:45:05
合計ジャッジ時間 21,321 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 16 ms
7,636 KB
testcase_01 AC 16 ms
7,648 KB
testcase_02 AC 2,068 ms
8,088 KB
testcase_03 AC 1,646 ms
8,256 KB
testcase_04 AC 873 ms
8,136 KB
testcase_05 AC 589 ms
7,840 KB
testcase_06 AC 212 ms
7,992 KB
testcase_07 AC 19 ms
7,784 KB
testcase_08 AC 278 ms
7,900 KB
testcase_09 AC 2,006 ms
8,172 KB
testcase_10 AC 16 ms
7,812 KB
testcase_11 AC 1,862 ms
8,148 KB
testcase_12 AC 2,570 ms
8,092 KB
testcase_13 AC 1,756 ms
8,216 KB
testcase_14 AC 2,014 ms
8,148 KB
testcase_15 AC 1,846 ms
8,036 KB
testcase_16 AC 47 ms
7,868 KB
testcase_17 AC 1,193 ms
8,008 KB
testcase_18 AC 992 ms
8,200 KB
testcase_19 AC 34 ms
7,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def solve(N, A, B):
    record = N
    BB = B + B
    pq0 = [(a, 0) for a in A]
    heapq.heapify(pq0)
    for i in range(N):
        pq = pq0[:]
        for b in BB[i:i + N]:
            a, n = pq[0]
            heapq.heapreplace(pq, (a + b//2, n + 1))
        max_n = max(n for a, n in pq)
        if max_n < record:
            record = max_n
    return record

print(solve(N, A, B))
0