結果
問題 |
No.3114 0→1
|
ユーザー |
|
提出日時 | 2025-04-20 04:09:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 794 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 50,816 KB |
最終ジャッジ日時 | 2025-04-20 04:09:17 |
合計ジャッジ時間 | 6,883 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 29 |
ソースコード
import numpy as np def min_operations_to_make_good(s): n = len(s) arr = np.array([int(c) for c in s]) changed_positions = set() for i in range(n-1): zeros = 0 ones = 0 for j in range(i, n): if arr[j] == 0: zeros += 1 else: ones += 1 if j > i and zeros >= ones: for k in range(i, j+1): if arr[k] == 0: arr[k] = 1 changed_positions.add(k) zeros -= 1 ones += 1 break return len(changed_positions) n = int(input()) s = input().strip() print(min_operations_to_make_good(s))