結果

問題 No.1606 Stuffed Animals Keeper
ユーザー 👑 Kazun
提出日時 2021-07-16 22:18:02
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 429 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 72,068 KB
最終ジャッジ日時 2024-07-06 09:40:18
合計ジャッジ時間 4,741 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 2
other AC * 9 RE * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#=================================================
N=int(input())
A=list(map(int,input().split()))+[2]

#===
P=A.count(0)
Q=A.count(1)

#=== 可能どうかの判定
X=[]
x=0
for a in A:
    if a!=2:
        x+=1
    else:
        if x:
            X.append(x)
        x=0

DP=[0]*(P+1); DP[0]=1
for x in X:
    for k in range(P,x-1,-1):
        DP[k]|=DP[k-x]

if DP[P]==0:
    exit(print(-1))

#=== 回数を求める
assert 0
0