結果
問題 | No.50 おもちゃ箱 |
ユーザー |
![]() |
提出日時 | 2023-09-01 12:17:34 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 142 ms / 5,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,368 KB |
最終ジャッジ日時 | 2025-01-03 06:29:45 |
合計ジャッジ時間 | 4,230 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 38 |
ソースコード
N = int(input()) A = list(map(int, input().split())) M = int(input()) B = list(map(int, input().split())) B.sort(reverse=True) inf = 10 ** 18 ans = inf def dfs(L = [], now = 0): global ans if len(L) > len(B) or len(L) >= ans: return if now == N: temp = [] for a in L: temp.append(a) temp.sort(reverse=True) for i in range(len(temp)): if temp[i] > B[i]: return ans = min(ans, len(temp)) return for i in range(len(L)): L[i] += A[now] dfs(L, now + 1) L[i] -= A[now] L.append(A[now]) dfs(L, now + 1) L.pop() return dfs() print(ans) if ans != inf else print(-1)