結果

問題 No.50 おもちゃ箱
コンテスト
ユーザー むらため
提出日時 2019-02-05 10:37:03
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 489 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,498 ms
コンパイル使用メモリ 71,960 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-22 11:21:46
合計ジャッジ時間 3,579 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 5 WA * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
/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 #
raw source code

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))==(1 shl i):S[n]+=A[i]))
var U=S.mapIt(B[0]-it>=0)
if U[K-1]:quit "1",0
for i in 0..<M:
 var V=S.mapIt(false)
 for x,a in U:
  if a:
   for y,s in S:
    if (x and y)==0 and B[i]-s>=0:V[x xor y]=true
 U=V
 if U[K-1]:quit $(i+2),0
echo -1
0