結果
問題 |
No.3114 0→1
|
ユーザー |
|
提出日時 | 2025-04-19 16:51:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 461 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 12,252 KB |
最終ジャッジ日時 | 2025-04-19 16:51:59 |
合計ジャッジ時間 | 2,867 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
def count_and_update(s): s_list = list(s) count = 0 for i in range(len(s_list)): if s_list[i] == '0': if (i >= 1 and s_list[i - 1] == '0') or (i >= 2 and s_list[i - 2] == '0'): count += 1 s_list[i] = '1' # 条件に合ったら '1' に変更 updated_s = ''.join(s_list) return count, updated_s n = int(input()) s = input().strip() count, updated_s = count_and_update(s) print(count)