結果
| 問題 | No.3114 0→1 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-20 04:59:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 600 bytes |
| 記録 | |
| コンパイル時間 | 212 ms |
| コンパイル使用メモリ | 11,904 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2025-04-20 04:59:55 |
| 合計ジャッジ時間 | 2,761 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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))