結果

問題 No.50 おもちゃ箱
ユーザー むらため
提出日時 2019-02-05 10:33:20
言語 Nim
(2.2.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 526 bytes
コンパイル時間 3,590 ms
コンパイル使用メモリ 67,152 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 11:24:16
合計ジャッジ時間 4,912 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 ia in 0..<N:
  if(n and(1 shl ia))==(1 shl ia):S[n] += A[ia]
var ans=S.mapIt(B[0]-it>=0)
if ans[K-1]:quit "1",0
for i,b in B[1..^1]:
 var n_ans = S.mapIt(false)
 for x,a in ans:
  if a:
   for y,s in S:
    if (x and y)==0 and b-s>=0:n_ans[x xor y]=true
 ans = n_ans
 if ans[K-1] : quit $(i+2),0
echo -1
0