結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー gew1fw
提出日時 2025-06-12 21:46:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 4,085 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 110,952 KB
最終ジャッジ日時 2025-06-12 21:53:30
合計ジャッジ時間 14,288 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 17 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input().strip()

groupA = []
groupB = []
groupC = []

for i in range(len(s)):
    if i % 3 == 0:
        groupA.append(s[i])
    elif i % 3 == 1:
        groupB.append(s[i])
    else:
        groupC.append(s[i])

count_A_c = groupA.count('c')
count_A_o = groupA.count('o')
count_A_n = groupA.count('n')

count_B_c = groupB.count('c')
count_B_o = groupB.count('o')
count_B_n = groupB.count('n')

count_C_c = groupC.count('c')
count_C_o = groupC.count('o')
count_C_n = groupC.count('n')

max0 = min(count_A_c, count_B_o, count_C_n)
max1 = min(count_B_c, count_C_o, count_A_n)
max2 = min(count_C_c, count_A_o, count_B_n)

total = max0 + max1 + max2
print(total)
0