結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー taiga0629kyopro
提出日時 2022-09-16 21:41:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 104,336 KB
最終ジャッジ日時 2024-12-21 18:49:13
合計ジャッジ時間 6,885 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=list(input())
from _collections import defaultdict
cnt=defaultdict(int)
for i in range(3*n):
    cnt[i%3,s[i]]+=1
ans=0
nokori=3*n
for j in range(3):
    res=min(cnt[j,"c"],cnt[(j+1)%3,"o"],cnt[(j+2)%3,"n"])
    while nokori-3*res<0 and res>0:res-=1
    ans+=res
    nokori-=3*res
    nokori-=1

print(ans)

0