結果

問題 No.9 モンスターのレベル上げ
ユーザー rpy3cpprpy3cpp
提出日時 2015-08-07 00:08:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,203 ms / 5,000 ms
コード長 491 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-09-06 03:57:35
合計ジャッジ時間 18,096 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,156 KB
testcase_01 AC 16 ms
7,984 KB
testcase_02 AC 1,759 ms
8,644 KB
testcase_03 AC 1,375 ms
8,560 KB
testcase_04 AC 735 ms
8,548 KB
testcase_05 AC 496 ms
8,472 KB
testcase_06 AC 173 ms
8,052 KB
testcase_07 AC 18 ms
8,000 KB
testcase_08 AC 236 ms
8,408 KB
testcase_09 AC 1,706 ms
8,528 KB
testcase_10 AC 15 ms
8,008 KB
testcase_11 AC 1,558 ms
8,384 KB
testcase_12 AC 2,203 ms
8,592 KB
testcase_13 AC 1,461 ms
8,616 KB
testcase_14 AC 1,686 ms
8,768 KB
testcase_15 AC 1,561 ms
8,612 KB
testcase_16 AC 42 ms
8,156 KB
testcase_17 AC 1,003 ms
8,428 KB
testcase_18 AC 848 ms
8,520 KB
testcase_19 AC 31 ms
8,180 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