結果

問題 No.50 おもちゃ箱
ユーザー むらため
提出日時 2019-02-05 10:38:46
言語 Nim
(2.2.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 476 bytes
コンパイル時間 3,639 ms
コンパイル使用メモリ 66,148 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 11:24:36
合計ジャッジ時間 5,042 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 9 WA * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 10) Warning: Deprecated since v1.5; Use auto instead.; any is deprecated [Deprecated]
/home/judge/data/code/Main.nim(3, 10) Warning: Deprecated since v1.5; Use auto instead.; any is deprecated [Deprecated]

ソースコード

diff #

import sequtils,strutils,algorithm
proc r():any=stdin.readLine.parseInt
proc R():any=stdin.readLine.split.map(parseInt).sorted(cmp,Descending)
var
 N=r()
 K=1 shl N
 A=R()
 M=r()
 B=R()
 S=newSeq[int]K
for n in 0..<K:(for i in 0..<N:(if(n and(1 shl i))>0:S[n]+=A[i]))
var U=S.mapIt(B[0]-it>=0)
if U[K-1]:quit "1",0
for i,b in B[1..^1]:
 var V=S.mapIt(false)
 for x,a in U:(if a:(for y,s in S:(if (x and y)==0 and b-s>=0:V[x xor y]=true)))
 U=V
 if U[K-1]:quit $(i+2),0
echo -1
0