結果

問題 No.9 モンスターのレベル上げ
ユーザー sue_charosue_charo
提出日時 2017-05-01 14:25:23
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 3,122 ms / 5,000 ms
コード長 994 bytes
コンパイル時間 60 ms
使用メモリ 9,932 KB
最終ジャッジ日時 2023-01-21 16:27:37
合計ジャッジ時間 25,413 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 28 ms
9,492 KB
testcase_01 AC 27 ms
9,396 KB
testcase_02 AC 2,434 ms
9,756 KB
testcase_03 AC 1,912 ms
9,688 KB
testcase_04 AC 1,018 ms
9,612 KB
testcase_05 AC 682 ms
9,744 KB
testcase_06 AC 263 ms
9,392 KB
testcase_07 AC 33 ms
9,292 KB
testcase_08 AC 340 ms
9,368 KB
testcase_09 AC 2,356 ms
9,716 KB
testcase_10 AC 28 ms
9,484 KB
testcase_11 AC 2,182 ms
9,932 KB
testcase_12 AC 3,122 ms
9,652 KB
testcase_13 AC 2,142 ms
9,584 KB
testcase_14 AC 2,375 ms
9,600 KB
testcase_15 AC 2,165 ms
9,632 KB
testcase_16 AC 65 ms
9,292 KB
testcase_17 AC 1,378 ms
9,684 KB
testcase_18 AC 1,187 ms
9,520 KB
testcase_19 AC 51 ms
9,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
 
 
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}
 
 
def solve(N, A, B):
    A.sort()
    A_heap = [(a, 0) for a in A]
    B_double = list(map(lambda b: b // 2, B)) * 2
    ans = INF
    for i in range(N):
        heap_copy = copy.copy(A_heap)
        ans_temp = 0
        for b in B_double[i: i + N]:
            now_mon = heapq.heappop(heap_copy)
            if ans_temp < now_mon[1] + 1:
                ans_temp = now_mon[1] + 1
            heapq.heappush(heap_copy, (now_mon[0] + b, now_mon[1] + 1))
        ans = min(ans, ans_temp)

    return ans


def main():
    N = II()
    A = ILI()
    B = ILI()
    print(solve(N, A, B))
 
 
if __name__ == "__main__":
    main()
0