結果
問題 |
No.3114 0→1
|
ユーザー |
|
提出日時 | 2025-04-30 16:01:27 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 744 bytes |
コンパイル時間 | 335 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2025-04-30 16:01:31 |
合計ジャッジ時間 | 3,299 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | WA * 30 |
ソースコード
def min_operations_to_good_string(N, S): count_0 = 0 count_1 = 0 operations = 0 # 文字列を走査 for char in S: if char == '0': count_0 += 1 else: count_1 += 1 # 直前の文字が0で、今が0の時 if count_0 > count_1 and (len(S) > 1 and char == '0'): operations += 1 # 1つの操作で1つの0を1に変えたことにする count_1 += 1 # 0を1に変えたと仮定する count_0 -= 1 # その分、0のカウントを減らす return operations # 入力の読み込み N = int(input().strip()) S = input().strip() # 結果の出力 result = min_operations_to_good_string(N, S) print(result)