結果
問題 |
No.3114 0→1
|
ユーザー |
|
提出日時 | 2025-04-20 14:11:28 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 538 bytes |
コンパイル時間 | 197 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 10,240 KB |
最終ジャッジ日時 | 2025-04-20 14:11:31 |
合計ジャッジ時間 | 2,005 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 30 |
ソースコード
def min_operations(s): n = len(s) # 各位置での累積差分(00の数 - 11の数) balance = [0] * (n + 1) for i in range(1, n): balance[i] = balance[i-1] if s[i-1:i+1] == "00": balance[i] += 1 elif s[i-1:i+1] == "11": balance[i] -= 1 # 最大のアンバランスを求める min_balance = 0 result = 0 for b in balance: result = max(result, b - min_balance) min_balance = min(min_balance, b) return result