結果
| 問題 |
No.3114 0→1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-20 01:03:59 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 756 bytes |
| コンパイル時間 | 230 ms |
| コンパイル使用メモリ | 12,160 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2025-04-20 01:04:03 |
| 合計ジャッジ時間 | 3,110 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 30 |
ソースコード
def min_operations_to_good_string(n, s):
operations = 0
i = 0
while i < n - 1:
if s[i] == '0':
count_0 = 1
count_1 = 0
j = i + 1
while j < n:
if s[j] == '0':
count_0 += 1
else:
count_1 += 1
if count_0 > count_1:
operations += 1
i = j + 1 # skip this window (greedy fix)
break
j += 1
else:
break # no more violations found
else:
i += 1
print(operations)
if __name__ == "__main__":
n = int(input())
s = input().strip()
min_operations_to_good_string(n, s)