結果

問題 No.2738 CPC To F
ユーザー rlangevinrlangevin
提出日時 2024-04-21 00:53:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 115,396 KB
最終ジャッジ日時 2024-04-21 00:53:29
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,840 KB
testcase_01 AC 39 ms
52,096 KB
testcase_02 AC 151 ms
110,840 KB
testcase_03 AC 135 ms
115,396 KB
testcase_04 AC 35 ms
52,520 KB
testcase_05 AC 34 ms
52,864 KB
testcase_06 AC 33 ms
52,948 KB
testcase_07 AC 34 ms
52,280 KB
testcase_08 AC 42 ms
60,540 KB
testcase_09 AC 54 ms
73,048 KB
testcase_10 AC 52 ms
61,056 KB
testcase_11 AC 59 ms
71,296 KB
testcase_12 AC 60 ms
72,576 KB
testcase_13 AC 63 ms
75,904 KB
testcase_14 AC 80 ms
76,544 KB
testcase_15 AC 65 ms
75,648 KB
testcase_16 AC 64 ms
76,032 KB
testcase_17 AC 64 ms
75,776 KB
testcase_18 AC 70 ms
80,384 KB
testcase_19 AC 65 ms
76,800 KB
testcase_20 AC 64 ms
77,056 KB
testcase_21 AC 71 ms
76,160 KB
testcase_22 AC 69 ms
77,440 KB
testcase_23 AC 65 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())

ans = 0
stack = ["?", "?", "?", "?", "?", "?"]
for i in range(N):
    if S[i] == "C":
        if stack[-6:] == ["C", "P", "C", "T", "C", "P"]:
            ans += 1
            stack.pop()
            stack.pop()
            stack.append("F")
            continue
    if S[i] == "F":
        if stack[-4:] == ["C", "P", "C", "T"]:
            ans += 1
        
    stack.append(S[i])
            
print(ans)        

        
0