No.2738 CPC To F
問題文最終更新日: 2024-04-19 01:07:00
English (AI translation)
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, andF
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もしくは右上の雲マークをクリックしてアカウントを作成してください。