結果
問題 |
No.50 おもちゃ箱
|
ユーザー |
|
提出日時 | 2015-02-23 17:05:28 |
言語 | PyPy2 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 489 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 77,080 KB |
実行使用メモリ | 78,328 KB |
最終ジャッジ日時 | 2024-06-23 22:08:20 |
合計ジャッジ時間 | 15,477 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 7 WA * 31 |
ソースコード
import itertools as it N = int(raw_input()) A = map(int,raw_input().split()) M = int(raw_input()) _B = sorted(map(int,raw_input().split()),reverse = True) ans = M for order in it.permutations(A,N): B = _B[:] i = j = 0 while i < N and j < M: if B[j] >= A[i]: B[j] -= A[i] i += 1 else: j += 1 if i == N: ans = min(ans, j+1) break if j+1 >= ans: break print ans if ans < 100 else -1