結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー lloyzlloyz
提出日時 2023-08-02 00:34:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 342 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 104,808 KB
最終ジャッジ日時 2024-10-11 20:09:33
合計ジャッジ時間 5,760 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n = int(input())
S = list(input())

C = [defaultdict(int) for _ in range(3)]
for i in range(3 * n):
    C[i % 3][S[i]] += 1
ANS = []
for i in range(3):
    ANS.append(min(C[i % 3]['c'], C[(i + 1) % 3]['o'], C[(i + 2) % 3]['n']))
ans = sum(ANS)
if ans == n:
    if ANS[0] != n:
        ans -= 1
print(ans)
0