結果
問題 |
No.3114 0→1
|
ユーザー |
|
提出日時 | 2025-04-20 04:02:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 792 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 51,188 KB |
最終ジャッジ日時 | 2025-04-20 04:02:12 |
合計ジャッジ時間 | 6,964 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 29 |
ソースコード
import numpy as np def min_operations_to_make_good(s): n = len(s) s_array = np.array(list(s)) operations = 0 for i in range(n): zeros = ones = 0 zero_indices = [] for j in range(i, n): if s_array[j] == '0': zeros += 1 zero_indices.append(j) else: ones += 1 if j - i + 1 >= 2: if zeros >= ones and len(zero_indices) > 0: leftmost_zero = zero_indices.pop(0) s_array[leftmost_zero] = '1' operations += 1 zeros -= 1 ones += 1 return operations n = int(input()) s = input().strip() print(min_operations_to_make_good(s))