結果
| 問題 |
No.1924 3 color painting on a line
|
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:15:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 451 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 81,880 KB |
| 実行使用メモリ | 77,776 KB |
| 最終ジャッジ日時 | 2025-06-12 20:18:17 |
| 合計ジャッジ時間 | 3,930 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 41 |
ソースコード
n = int(input())
s = input().strip()
if n == 0:
print(0)
exit()
# Split the string into runs
runs = []
current = s[0]
for c in s[1:]:
if c != current:
runs.append(current)
current = c
runs.append(current)
# Count the frequency of each run's color
from collections import defaultdict
freq = defaultdict(int)
for c in runs:
freq[c] += 1
max_freq = max(freq.values())
answer = (len(runs) - max_freq) + 1
print(answer)
gew1fw