結果
| 問題 | No.3114 0→1 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-20 04:59:52 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 600 bytes |
| 記録 | |
| コンパイル時間 | 282 ms |
| コンパイル使用メモリ | 21,280 KB |
| 実行使用メモリ | 15,864 KB |
| 最終ジャッジ日時 | 2026-07-10 01:29:16 |
| 合計ジャッジ時間 | 5,176 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | WA * 30 |
ソースコード
def min_operations_to_good_string(S):
N = len(S)
ones = S.count('1')
if ones == 0:
return 1
max_zeros = 0
current_zeros = 0
for char in S:
if char == '0':
current_zeros += 1
else:
max_zeros = max(max_zeros, current_zeros)
current_zeros = 0
max_zeros = max(max_zeros, current_zeros)
if max_zeros >= ones + 1:
return max_zeros - ones
else:
return 0
if __name__ == "__main__":
N = int(input())
S = input().strip()
print(min_operations_to_good_string(S))