結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー ygd.ygd.
提出日時 2022-09-16 23:09:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,418 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 77,448 KB
最終ジャッジ日時 2023-08-23 16:33:43
合計ジャッジ時間 5,363 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,336 KB
testcase_01 AC 69 ms
71,408 KB
testcase_02 AC 72 ms
71,204 KB
testcase_03 AC 68 ms
71,244 KB
testcase_04 AC 69 ms
71,348 KB
testcase_05 AC 83 ms
77,152 KB
testcase_06 AC 89 ms
77,240 KB
testcase_07 AC 67 ms
71,252 KB
testcase_08 AC 81 ms
76,424 KB
testcase_09 AC 79 ms
76,980 KB
testcase_10 AC 96 ms
77,176 KB
testcase_11 AC 94 ms
77,448 KB
testcase_12 AC 69 ms
71,252 KB
testcase_13 AC 81 ms
75,564 KB
testcase_14 AC 96 ms
76,876 KB
testcase_15 AC 83 ms
75,928 KB
testcase_16 AC 87 ms
77,056 KB
testcase_17 AC 69 ms
71,496 KB
testcase_18 AC 78 ms
75,952 KB
testcase_19 AC 87 ms
77,040 KB
testcase_20 AC 86 ms
76,856 KB
testcase_21 AC 86 ms
76,592 KB
testcase_22 AC 89 ms
77,440 KB
testcase_23 AC 71 ms
71,100 KB
testcase_24 AC 79 ms
75,704 KB
testcase_25 AC 86 ms
76,436 KB
testcase_26 AC 90 ms
77,432 KB
testcase_27 AC 70 ms
71,312 KB
testcase_28 AC 86 ms
77,088 KB
testcase_29 AC 79 ms
75,880 KB
testcase_30 AC 87 ms
76,492 KB
testcase_31 AC 80 ms
76,124 KB
testcase_32 AC 80 ms
75,768 KB
testcase_33 AC 79 ms
75,560 KB
testcase_34 AC 78 ms
75,816 KB
testcase_35 AC 81 ms
76,364 KB
testcase_36 AC 80 ms
75,824 KB
testcase_37 AC 81 ms
76,372 KB
testcase_38 AC 78 ms
75,616 KB
testcase_39 AC 84 ms
76,660 KB
testcase_40 AC 82 ms
76,276 KB
testcase_41 AC 83 ms
76,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
import math
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
#from collections import defaultdict 
#from collections import deque
#import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
#MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    n = int(input())
    S = str(input())

    C = [0,0,0]; O = [0,0,0]; N = [0,0,0]

    for i in range(3*n):
        if S[i] == 'c':
            C[i%3] += 1
        if S[i] == 'o':
            O[i%3] += 1
        if S[i] == 'n':
            N[i%3] += 1
    
    first = min(C[0],O[1],N[2])
    second = min(C[1],O[2],N[0])
    third = min(C[2],O[0],N[1])
    # print(C,O,N,first,second,third)

    block = first
    ans = first

    if second > 0:
        block += second + 1
        if block > n:
            ans += second-1
            print(ans);exit()
        else:
            ans += second
    
    if third > 0:
        if second > 0:
            block += third
        else:
            block += third + 1

        if block > n:
            ans += third - 1
        else:
            ans += third
    print(ans)


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