結果
問題 | No.50 おもちゃ箱 |
ユーザー | むらため |
提出日時 | 2017-08-15 14:39:45 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 22 ms / 5,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 3,724 ms |
コンパイル使用メモリ | 71,988 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-12 14:33:28 |
合計ジャッジ時間 | 5,442 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 8 ms
4,384 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 4 ms
4,380 KB |
testcase_06 | AC | 4 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,384 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,376 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 6 ms
4,376 KB |
testcase_18 | AC | 3 ms
4,380 KB |
testcase_19 | AC | 11 ms
4,380 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | AC | 4 ms
4,380 KB |
testcase_22 | AC | 9 ms
4,380 KB |
testcase_23 | AC | 2 ms
4,376 KB |
testcase_24 | AC | 2 ms
4,380 KB |
testcase_25 | AC | 2 ms
4,376 KB |
testcase_26 | AC | 2 ms
4,380 KB |
testcase_27 | AC | 3 ms
4,380 KB |
testcase_28 | AC | 14 ms
4,380 KB |
testcase_29 | AC | 22 ms
4,380 KB |
testcase_30 | AC | 16 ms
4,384 KB |
testcase_31 | AC | 2 ms
4,376 KB |
testcase_32 | AC | 13 ms
4,380 KB |
testcase_33 | AC | 12 ms
4,380 KB |
testcase_34 | AC | 6 ms
4,380 KB |
testcase_35 | AC | 12 ms
4,380 KB |
testcase_36 | AC | 13 ms
4,376 KB |
testcase_37 | AC | 10 ms
4,380 KB |
testcase_38 | AC | 18 ms
4,380 KB |
testcase_39 | AC | 10 ms
4,380 KB |
testcase_40 | AC | 6 ms
4,376 KB |
testcase_41 | AC | 19 ms
4,380 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 50) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated] /home/judge/data/code/Main.nim(1, 57) Warning: imported and not used: 'macros' [UnusedImport] /home/judge/data/code/Main.nim(6, 8) Warning: imported and not used: 'times' [UnusedImport] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'strscans' [UnusedImport] /home/judge/data/code/Main.nim(1, 50) Warning: imported and not used: 'future' [UnusedImport]
ソースコード
import sequtils,strutils,strscans,algorithm,math,future,macros template get*():string = stdin.readLine() #.strip() template `max=`*(x,y:typed):void = x = max(x,y) template optPow{`^`(2,n)}(n:int) : int = 1 shl n template If*(ex:untyped):untyped = (if not(ex) : continue) import times let N = get().parseInt() A = get().split().map(parseInt).sorted(cmp,Descending) # toy <20 M = get().parseInt() B = get().split().map(parseInt).sorted(cmp,Descending) # box <20 var state = newSeqWith(2^N,0) for n in 0 ..< 2^N: for ia in 0 ..< N: If: (n and 2^ia) == 2^ia state[n] += A[ia] # 各状態の体積の和 var ans = state.mapIt(B[0] - it >= 0) if ans[2^N - 1] : echo 1 quit() for i,b in B[1..^1]: var n_ans = state.mapIt(false) for x,a in ans: If: a for y,s in state: If: (x and y) == 0 If: b - s >= 0 n_ans[x xor y] = true ans = n_ans if ans[2^N - 1] : echo i+2 quit() echo -1