結果
問題 | No.1606 Stuffed Animals Keeper |
ユーザー |
👑 ![]() |
提出日時 | 2021-07-16 22:16:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 594 bytes |
コンパイル時間 | 218 ms |
コンパイル使用メモリ | 82,388 KB |
実行使用メモリ | 66,700 KB |
最終ジャッジ日時 | 2024-07-06 09:36:28 |
合計ジャッジ時間 | 4,115 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 WA * 21 |
ソースコード
#=================================================N=int(input())A=list(map(int,input().split()))+[2]#===P=A.count(0)Q=A.count(1)#=== 可能どうかの判定X=[]x=0for a in A:if a!=2:x+=1else:if x:X.append(x)x=0DP=[0]*(P+1); DP[0]=1for x in X:for k in range(P,x-1,-1):DP[k]|=DP[k-x]if DP[P]==0:exit(print(-1))#=== 回数を求めるY=[]p=q=0for a in A:if a==0:p+=1elif a==1:q+=1else:Y.append((p,q))p=q=0K=0for p,q in Y:K+=min(p,q)print(K//2)