No.1542 Pon Pon Pon, Pon Pon Pon Pon, Pon Pon Pon
Problem Statement
There is a string $S$, which is initially ponpon. The following operation, choosing one of the 2 options below, was repeated 0 or more times on $S$.
- Insert
pon. - Insert any 1 character among
p,o,n.
Given $S$ after the operations, find the maximum possible number of times operation 1. was performed.
However, if $S$ cannot be obtained by repeating operations 1. and 2., print -1.
Input
$N$ $S$
- $1 \leqq N \leqq 500$
- The length of the string $S$ is $N$
- The string $S$ is guaranteed to consist only of the 3 kinds of characters
p,o,n.
Output
Print a newline at the end.
Sample
Sample 1
Input
9 ponpponon
Output
1
pon is inserted once after the p at the 4th character.
Sample 2
Input
9 pponoponn
Output
0
Only operation 2. was performed.
Sample 3
Input
12 pppoponnonon
Output
-1
If the string cannot be obtained by performing operations 1. and 2. on ponpon, print -1.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
57tggx
logx
Re_menal2
とりゐ
pepper_aobuta