問題一覧 > 通常問題

No.2738 CPC To F

レベル : / AI推定難易度 : 1100 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 118
作問者 : ponjuice / テスター : kenken714 cho435 Nzt3 tassei903
お気に入りにしたユーザー ProblemId : 10841 / 自分の提出
問題文最終更新日: 2024-04-19 01:07:00
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
CPCTF 2024 : PPC (順位表) の他の問題:

Problem Statement

You are given a string $S$ of length $N$ consisting of C, P, T, and F.
You have the power to look for a substring CPC in this string and change a chosen CPC into F.
Given that you may use this power any number of times, what is the maximum number of substrings CPCTF you can make the string contain?

Constraints

  • $N$ is an integer
  • $5 \le N \le 5 \times 10^5$
  • $S$ is a string of length $N$
  • $S$ consists of C, P, T, and F

Input

The input is given from standard input in the following format.

$N$   
$S$

Output

Output the answer.

Sample

Sample 1
Input
12
CPCTFCPCTCPC
Output
2

By changing the CPC at characters $10,11,12$ into F, you can obtain the string CPCTFCPCTF. This string contains $2$ occurrences of CPCTF, and this is the maximum.

Sample 2
Input
5
CPCTF
Output
1

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。