結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー shotoyooshotoyoo
提出日時 2022-09-16 21:46:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 1,102 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 123,340 KB
最終ジャッジ日時 2023-08-23 14:47:16
合計ジャッジ時間 8,102 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
74,176 KB
testcase_01 AC 115 ms
74,344 KB
testcase_02 AC 115 ms
74,716 KB
testcase_03 AC 115 ms
74,572 KB
testcase_04 AC 113 ms
74,220 KB
testcase_05 AC 185 ms
123,144 KB
testcase_06 AC 186 ms
123,160 KB
testcase_07 AC 118 ms
74,544 KB
testcase_08 AC 164 ms
105,012 KB
testcase_09 AC 171 ms
114,556 KB
testcase_10 AC 192 ms
122,968 KB
testcase_11 AC 191 ms
123,040 KB
testcase_12 AC 118 ms
74,588 KB
testcase_13 AC 126 ms
78,996 KB
testcase_14 AC 175 ms
118,548 KB
testcase_15 AC 136 ms
89,236 KB
testcase_16 AC 188 ms
123,340 KB
testcase_17 AC 114 ms
74,080 KB
testcase_18 AC 122 ms
79,176 KB
testcase_19 AC 186 ms
122,976 KB
testcase_20 AC 164 ms
109,064 KB
testcase_21 AC 158 ms
104,900 KB
testcase_22 AC 184 ms
123,088 KB
testcase_23 AC 113 ms
74,340 KB
testcase_24 AC 122 ms
77,996 KB
testcase_25 AC 159 ms
104,952 KB
testcase_26 AC 187 ms
123,060 KB
testcase_27 AC 113 ms
74,172 KB
testcase_28 AC 169 ms
114,544 KB
testcase_29 AC 137 ms
88,004 KB
testcase_30 AC 162 ms
108,840 KB
testcase_31 AC 137 ms
89,752 KB
testcase_32 AC 123 ms
80,976 KB
testcase_33 AC 128 ms
84,104 KB
testcase_34 AC 126 ms
81,684 KB
testcase_35 AC 151 ms
98,448 KB
testcase_36 AC 133 ms
85,496 KB
testcase_37 AC 153 ms
98,172 KB
testcase_38 AC 126 ms
81,980 KB
testcase_39 AC 156 ms
101,960 KB
testcase_40 AC 149 ms
98,216 KB
testcase_41 AC 155 ms
101,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, random
input = lambda : sys.stdin.readline().rstrip()


write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18
LI = lambda : list(map(int, input().split())); II=lambda : int(input()); SI=lambda : [ord(c)-ord("a") for c in input()]
def debug(_l_):
    for s in _l_.split():
        print(f"{s}={eval(s)}", end=" ")
    print()
def dlist(*l, fill=0):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [dlist(*ll, fill=fill) for _ in range(l[0])]

n = int(input())
s = SI()
l = [[],[],[]]
for i in range(3*n):
    l[i%3].append(s[i])
from collections import Counter
C = ord("c")-ord("a")
O = ord("o")-ord("a")
N = ord("n")-ord("a")
cs = [Counter(item) for item in l]
ans = 0
val = min(cs[0][C], cs[1][O], cs[2][N])
val2 = min(cs[1][C], cs[2][O], cs[0][N])
if val2==n:
    val2 = n-1
val3 = min(cs[2][C], cs[0][O], cs[1][N])
if val3==n:
    val3 = n-1
ans = val + val2 + val3
if ans==n and val!=n:
    ans = n-1
print(ans)
0