結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー dn6049949dn6049949
提出日時 2022-09-16 22:29:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 78,428 KB
最終ジャッジ日時 2023-08-23 16:05:48
合計ジャッジ時間 6,368 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,676 KB
testcase_01 AC 88 ms
71,680 KB
testcase_02 AC 92 ms
71,588 KB
testcase_03 AC 92 ms
71,756 KB
testcase_04 AC 93 ms
71,380 KB
testcase_05 AC 111 ms
77,928 KB
testcase_06 AC 116 ms
78,264 KB
testcase_07 AC 91 ms
71,464 KB
testcase_08 AC 106 ms
77,608 KB
testcase_09 AC 108 ms
77,740 KB
testcase_10 AC 121 ms
78,216 KB
testcase_11 AC 120 ms
78,428 KB
testcase_12 AC 92 ms
71,836 KB
testcase_13 AC 104 ms
76,752 KB
testcase_14 AC 117 ms
78,068 KB
testcase_15 AC 107 ms
77,168 KB
testcase_16 AC 113 ms
77,956 KB
testcase_17 AC 91 ms
71,660 KB
testcase_18 AC 102 ms
76,464 KB
testcase_19 AC 113 ms
78,064 KB
testcase_20 AC 111 ms
77,696 KB
testcase_21 AC 108 ms
77,452 KB
testcase_22 AC 112 ms
78,124 KB
testcase_23 AC 93 ms
71,652 KB
testcase_24 AC 100 ms
76,352 KB
testcase_25 AC 108 ms
77,244 KB
testcase_26 AC 114 ms
77,940 KB
testcase_27 AC 91 ms
71,768 KB
testcase_28 AC 109 ms
77,716 KB
testcase_29 AC 101 ms
76,840 KB
testcase_30 AC 109 ms
77,536 KB
testcase_31 AC 106 ms
76,932 KB
testcase_32 AC 100 ms
76,728 KB
testcase_33 AC 105 ms
76,776 KB
testcase_34 AC 102 ms
76,856 KB
testcase_35 AC 107 ms
77,464 KB
testcase_36 AC 102 ms
76,684 KB
testcase_37 AC 107 ms
77,440 KB
testcase_38 AC 103 ms
76,800 KB
testcase_39 AC 110 ms
77,732 KB
testcase_40 AC 108 ms
77,512 KB
testcase_41 AC 109 ms
77,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def main():
    n = I()
    s = input()
    count_c = [0]*3
    count_o = [0]*3
    count_n = [0]*3
    for i,si in enumerate(s):
        if si == "c":
            count_c[i%3] += 1
        elif si == "o":
            count_o[i%3] += 1
        elif si == "n":
            count_n[i%3] += 1
    c = [count_c, count_o, count_n]
    ans = 0
    for i in range(3):
        m = float("inf")
        for j in range(3):
            m = min(m, c[j][(i+j)%3])
        ans += m
    if ans == n and c != [[n,0,0],[0,n,0],[0,0,n]]:
        ans -= 1
    print(ans)
    return


if __name__ == "__main__":
    main()
0