結果

問題 No.9 モンスターのレベル上げ
ユーザー sue_charosue_charo
提出日時 2017-05-01 14:25:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,385 ms / 5,000 ms
コード長 994 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 10,492 KB
最終ジャッジ日時 2023-09-06 05:15:28
合計ジャッジ時間 19,464 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,032 KB
testcase_01 AC 30 ms
10,156 KB
testcase_02 AC 1,859 ms
10,484 KB
testcase_03 AC 1,461 ms
10,324 KB
testcase_04 AC 788 ms
10,384 KB
testcase_05 AC 528 ms
10,280 KB
testcase_06 AC 205 ms
10,188 KB
testcase_07 AC 34 ms
10,128 KB
testcase_08 AC 264 ms
10,180 KB
testcase_09 AC 1,791 ms
10,440 KB
testcase_10 AC 31 ms
10,032 KB
testcase_11 AC 1,671 ms
10,492 KB
testcase_12 AC 2,385 ms
10,348 KB
testcase_13 AC 1,605 ms
10,440 KB
testcase_14 AC 1,798 ms
10,444 KB
testcase_15 AC 1,617 ms
10,360 KB
testcase_16 AC 59 ms
10,076 KB
testcase_17 AC 1,050 ms
10,288 KB
testcase_18 AC 900 ms
10,420 KB
testcase_19 AC 47 ms
10,112 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