結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
![]() |
提出日時 | 2017-05-01 14:25:23 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 3,053 ms / 5,000 ms |
コード長 | 994 bytes |
コンパイル時間 | 109 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 12,032 KB |
最終ジャッジ日時 | 2024-06-23 23:58:07 |
合計ジャッジ時間 | 23,205 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
# 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()