結果

問題 No.50 おもちゃ箱
ユーザー pluto77pluto77
提出日時 2016-08-05 14:00:38
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,370 ms / 5,000 ms
コード長 396 bytes
コンパイル時間 1,394 ms
コンパイル使用メモリ 77,224 KB
実行使用メモリ 79,412 KB
最終ジャッジ日時 2023-09-08 04:21:35
合計ジャッジ時間 19,045 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
79,000 KB
testcase_01 AC 827 ms
79,028 KB
testcase_02 AC 80 ms
79,024 KB
testcase_03 AC 73 ms
76,248 KB
testcase_04 AC 71 ms
76,452 KB
testcase_05 AC 520 ms
79,412 KB
testcase_06 AC 139 ms
79,172 KB
testcase_07 AC 72 ms
76,116 KB
testcase_08 AC 72 ms
76,436 KB
testcase_09 AC 72 ms
76,452 KB
testcase_10 AC 76 ms
76,348 KB
testcase_11 AC 75 ms
77,532 KB
testcase_12 AC 74 ms
76,476 KB
testcase_13 AC 74 ms
76,136 KB
testcase_14 AC 83 ms
78,940 KB
testcase_15 AC 74 ms
76,140 KB
testcase_16 AC 82 ms
78,948 KB
testcase_17 AC 551 ms
78,948 KB
testcase_18 AC 125 ms
78,988 KB
testcase_19 AC 1,370 ms
79,076 KB
testcase_20 AC 88 ms
78,896 KB
testcase_21 AC 174 ms
78,924 KB
testcase_22 AC 635 ms
78,932 KB
testcase_23 AC 104 ms
79,020 KB
testcase_24 AC 73 ms
76,480 KB
testcase_25 AC 74 ms
76,388 KB
testcase_26 AC 84 ms
78,876 KB
testcase_27 AC 133 ms
79,120 KB
testcase_28 AC 805 ms
79,260 KB
testcase_29 AC 799 ms
79,152 KB
testcase_30 AC 618 ms
79,264 KB
testcase_31 AC 72 ms
76,372 KB
testcase_32 AC 786 ms
79,044 KB
testcase_33 AC 802 ms
79,072 KB
testcase_34 AC 812 ms
79,116 KB
testcase_35 AC 726 ms
79,368 KB
testcase_36 AC 803 ms
78,992 KB
testcase_37 AC 776 ms
79,200 KB
testcase_38 AC 787 ms
78,844 KB
testcase_39 AC 780 ms
79,256 KB
testcase_40 AC 640 ms
79,232 KB
testcase_41 AC 801 ms
79,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#coding: utf-8
#yuki50

from itertools import permutations

n=int(raw_input())
a=map(int,raw_input().split())
m=int(raw_input())
b=map(int,raw_input().split())

a.sort()
b.sort()
b.reverse()

res=m+1
for perm in permutations(a,n):
 temp=b[:]
 i,j=0,0
 while i<n and j<m:
  if temp[j]>=perm[i]:
   temp[j]-=perm[i]
   i+=1
  else:
   j+=1
 res=min(res,j+1)

if res<m+1:
 print res
else:
 print -1
0