結果
問題 |
No.50 おもちゃ箱
|
ユーザー |
|
提出日時 | 2019-01-29 04:28:07 |
言語 | Nim (2.2.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,097 bytes |
コンパイル時間 | 3,701 ms |
コンパイル使用メモリ | 75,676 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 11:07:31 |
合計ジャッジ時間 | 4,921 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 37 WA * 1 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(32, 9) Warning: assign is deprecated [Deprecated] /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]
ソースコード
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