結果
| 問題 |
No.3114 0→1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 11:11:37 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 77 ms / 2,000 ms |
| コード長 | 404 bytes |
| コンパイル時間 | 168 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2025-04-19 11:11:40 |
| 合計ジャッジ時間 | 3,282 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import sys
def min_flips_to_good(S: str) -> int:
total = S.count('0')
last = -10
cnt = 0
for i, c in enumerate(S):
if c == '0' and i - last >= 3:
cnt += 1
last = i
return total - cnt
def main():
input = sys.stdin.readline
n = int(input().strip())
S = input().strip()
print(min_flips_to_good(S))
if __name__ == "__main__":
main()