結果
| 問題 |
No.3114 0→1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 17:30:51 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 562 bytes |
| コンパイル時間 | 379 ms |
| コンパイル使用メモリ | 11,904 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2025-04-19 17:31:01 |
| 合計ジャッジ時間 | 3,927 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 30 |
ソースコード
import sys
def solve():
n = int(sys.stdin.readline())
s = list(sys.stdin.readline().strip())
count = 0
i = 0
# n-1 まで
while i < n - 1:
# "010" をチェック
if i + 2 < n and s[i] == '0' and s[i+1] == '1' and s[i+2] == '0':
s[i+2] = '1'
count += 1
# "00" をチェック
elif i + 1 < n and s[i] == '0' and s[i+1] == '0':
s[i+1] = '1'
count += 1
# 次の開始位置へ
i += 1
print(count)
if __name__ == "__main__":
solve()