結果

問題 No.50 おもちゃ箱
ユーザー むらためむらため
提出日時 2019-01-29 04:28:07
言語 Nim
(2.0.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,097 bytes
コンパイル時間 3,034 ms
コンパイル使用メモリ 70,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 03:12:06
合計ジャッジ時間 5,043 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 8) Warning: imported and not used: 'sets' [UnusedImport]
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'strscans' [UnusedImport]
/home/judge/data/code/Main.nim(2, 13) Warning: imported and not used: 'tables' [UnusedImport]
/home/judge/data/code/Main.nim(1, 45) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 50) Warning: imported and not used: 'sugar' [UnusedImport]
/home/judge/data/code/Main.nim(1, 56) Warning: imported and not used: 'macros' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,strscans,algorithm,math,sugar,macros
import sets,tables,intsets
template `max=`*(x,y:typed):void = x = max(x,y)
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
template `^`(n:int) : int = (1 shl n)
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': return
    result = 10 * result + k.ord - '0'.ord

let n = scan()
let A = newSeqWith(n,scan()).sorted(cmp,Descending)
let m = scan()
let B = newSeqWith(m,scan()).sorted(cmp,Descending)

var state = newSeq[int](^n)
for ni in 0..<(^n):
  for ia in 0..<n:
    if (ni and ^ia) != ^ia : continue
    state[ni] += A[ia] # 各状態の体積の和

proc getOKState(b:int): IntSet =
  result = initIntSet()
  for i,s in state:
    if b - s >= 0 : result.incl(i)

var ans = B[0].getOKState()
if ^n - 1 in ans: quit("1",0)
for i,b in B[1..^1]:
  var n_ans : IntSet
  n_ans.assign(ans)
  for x in b.getOKState().items:
    for y in ans.items:
      if (x and y) != 0 : continue
      n_ans.incl(x xor y)
  ans = n_ans
  if ^n - 1 in ans:
    echo i + 2
    quit 0
echo -1
0