結果
| 問題 |
No.50 おもちゃ箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-15 14:39:45 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 5,000 ms |
| コード長 | 938 bytes |
| コンパイル時間 | 3,651 ms |
| コンパイル使用メモリ | 80,004 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 02:37:35 |
| 合計ジャッジ時間 | 4,319 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 |
コンパイルメッセージ
/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