結果
| 問題 |
No.50 おもちゃ箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-17 23:00:57 |
| 言語 | Nim (2.2.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,162 bytes |
| コンパイル時間 | 5,685 ms |
| コンパイル使用メモリ | 78,648 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2025-03-12 14:41:53 |
| 合計ジャッジ時間 | 12,176 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | AC * 1 TLE * 1 -- * 36 |
コンパイルメッセージ
/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(33, 9) Warning: assign is deprecated [Deprecated] /home/judge/data/code/Main.nim(2, 13) Warning: imported and not used: 'tables' [UnusedImport] /home/judge/data/code/Main.nim(1, 50) Warning: imported and not used: 'future' [UnusedImport] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'strscans' [UnusedImport] /home/judge/data/code/Main.nim(2, 8) Warning: imported and not used: 'sets' [UnusedImport] /home/judge/data/code/Main.nim(1, 57) Warning: imported and not used: 'macros' [UnusedImport]
ソースコード
import sequtils,strutils,strscans,algorithm,math,future,macros
import sets,tables,intsets
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)
proc enumerate[T](arr:seq[T]): seq[tuple[i:int,val:T]] =
result = @[]; for i,a in arr: result &= (i,a)
let
N = get().parseInt()
A = get().split().map(parseInt).sorted(cmp,Descending)
M = get().parseInt()
B = get().split().map(parseInt).sorted(cmp,Descending)
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] # 各状態の体積の和
proc getOKState(b:int): IntSet =
result = initIntSet()
for i in state.enumerate().filterIt(b-it.val >= 0).mapIt(it.i):
result.incl(i)
var ans = B[0].getOKState()
if 2^N-1 in ans:
echo 1
quit()
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
n_ans.incl(x xor y)
ans = n_ans
if 2^N-1 in ans:
echo i + 2
quit()
echo -1