結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー 👑 rin204
提出日時 2022-09-16 21:32:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 431 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-12-21 18:28:31
合計ジャッジ時間 4,351 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
cnt = [[0] * 3 for _ in range(3)]
for i, s in enumerate(S):
    if s == "c":
        cnt[i % 3][0] += 1
    elif s == "o":
        cnt[i % 3][1] += 1
    elif s == "n":
        cnt[i % 3][2] += 1


ans = 0
lst = []
for i in range(3):
    mi = 1 << 30
    for j in range(3):
        mi = min(mi, cnt[(i + j) % 3][j])
    lst.append(mi)
    ans += mi
if ans == n and n != lst[0]:
    ans -= 1
print(ans)
0