結果
| 問題 | No.50 おもちゃ箱 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-02 21:49:02 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,025 ms / 5,000 ms |
| + 125µs | |
| コード長 | 671 bytes |
| 記録 | |
| コンパイル時間 | 1,231 ms |
| コンパイル使用メモリ | 80,848 KB |
| 実行使用メモリ | 84,324 KB |
| 最終ジャッジ日時 | 2026-09-23 10:22:45 |
| 合計ジャッジ時間 | 16,702 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 |
ソースコード
import itertools
import copy
N = int(input())
lsA = list(map(int,input().split()))
M = int(input())
lsB = list(map(int,input().split()))
lsB.sort(reverse=True)
lsp = itertools.permutations(lsA)
cnt = float('INF')
for p in lsp:
lsB1 = copy.copy(lsB)
for i in range(N):
f = False
for j in range(M):
if lsB1[j] >= p[i]:
lsB1[j] -= p[i]
f = True
break
if f == False:
break
if f:
ii = 0
for j in range(M):
if lsB1[j] != lsB[j]:
ii += 1
cnt = min(ii,cnt)
if cnt == float('INF'):
print(-1)
else:
print(cnt)