結果
| 問題 |
No.3114 0→1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 05:56:12 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 172 ms / 2,000 ms |
| コード長 | 421 bytes |
| コンパイル時間 | 595 ms |
| コンパイル使用メモリ | 11,776 KB |
| 実行使用メモリ | 17,024 KB |
| 最終ジャッジ日時 | 2025-04-19 05:56:18 |
| 合計ジャッジ時間 | 5,608 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import bisect
n = int(input())
s = input().strip()
pos = [i for i in range(n) if s[i] == '0']
m = len(pos)
if m <= 1:
print(0)
else:
dp = [0] * m
dp[0] = 1
for i in range(1, m):
target = pos[i] - 3
j = bisect.bisect_right(pos, target) - 1
if j >= 0:
current = dp[j] + 1
else:
current = 1
dp[i] = max(dp[i-1], current)
print(m - dp[-1])