結果
問題 | No.1606 Stuffed Animals Keeper |
ユーザー |
|
提出日時 | 2021-07-16 23:13:59 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 410 bytes |
コンパイル時間 | 263 ms |
コンパイル使用メモリ | 82,084 KB |
実行使用メモリ | 64,632 KB |
最終ジャッジ日時 | 2024-07-06 10:47:15 |
合計ジャッジ時間 | 3,504 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 42 |
ソースコード
N = int(input()) A =list(map(int,input().split())) l = [] zero,one = 0,0 for a,i in zip(A,range(N)): if a == 0: zero += 1 elif a == 1: one += 1 else: if zero != 0 and one != 0: l.append(abs(zero-one)) zero,one = 0,0 if zero != 0 and one != 0: l.append(abs(zero-one)) if l == []: print(0) elif len(l) == 1: print(-1) else: l.sort() ans = sum(l[:len(l)//2]) print(ans)