結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー ygd.ygd.
提出日時 2022-09-16 23:09:11
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,418 bytes
コンパイル時間 262 ms
使用メモリ 82,172 KB
最終ジャッジ日時 2023-01-11 08:23:36
合計ジャッジ時間 5,891 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 76 ms
75,708 KB
testcase_01 AC 75 ms
75,752 KB
testcase_02 AC 75 ms
75,656 KB
testcase_03 AC 75 ms
75,868 KB
testcase_04 AC 75 ms
75,704 KB
testcase_05 AC 88 ms
81,800 KB
testcase_06 AC 94 ms
82,132 KB
testcase_07 AC 75 ms
75,700 KB
testcase_08 AC 88 ms
81,344 KB
testcase_09 AC 90 ms
81,652 KB
testcase_10 AC 102 ms
82,028 KB
testcase_11 AC 102 ms
82,172 KB
testcase_12 AC 75 ms
75,788 KB
testcase_13 AC 88 ms
80,364 KB
testcase_14 AC 102 ms
81,792 KB
testcase_15 AC 89 ms
80,624 KB
testcase_16 AC 95 ms
81,780 KB
testcase_17 AC 77 ms
75,704 KB
testcase_18 AC 85 ms
80,540 KB
testcase_19 AC 94 ms
81,788 KB
testcase_20 AC 90 ms
81,516 KB
testcase_21 AC 90 ms
81,260 KB
testcase_22 AC 94 ms
82,000 KB
testcase_23 AC 76 ms
75,784 KB
testcase_24 AC 84 ms
80,344 KB
testcase_25 AC 90 ms
81,212 KB
testcase_26 AC 93 ms
82,124 KB
testcase_27 AC 76 ms
75,564 KB
testcase_28 AC 92 ms
81,592 KB
testcase_29 AC 86 ms
80,700 KB
testcase_30 AC 92 ms
81,256 KB
testcase_31 AC 87 ms
80,824 KB
testcase_32 AC 85 ms
80,464 KB
testcase_33 AC 87 ms
80,468 KB
testcase_34 AC 87 ms
80,460 KB
testcase_35 AC 90 ms
80,936 KB
testcase_36 AC 86 ms
80,576 KB
testcase_37 AC 91 ms
81,072 KB
testcase_38 AC 87 ms
80,656 KB
testcase_39 AC 91 ms
81,284 KB
testcase_40 AC 90 ms
81,184 KB
testcase_41 AC 91 ms
81,036 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