atcoder#ABC300F. [ABC300F] More Holidays
[ABC300F] More Holidays
Score : points
Problem Statement
You are given a string of length consisting of o
and x
, and integers and .
is guaranteed to contain at least one x
.
Let be the string of length obtained by concatenating copies of .
Consider replacing exactly x
's in with o
.
Your objective is to have as long a contiguous substring consisting of o
as possible in the resulting .
Find the maximum length of a contiguous substring consisting of o
that you can obtain.
Constraints
- , , and are integers.
- , where is the number of
x
's in the string . - is a string of length consisting of
o
andx
. - has at least one
x
.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
10 1 2
ooxxooooox
9
ooxxooooox
and ooxxooooox
.
Replacing x
at the third and fourth characters with o
makes ooooooooox
.
Now we have a length- contiguous substring consisting of o
, which is the longest possible.
5 3 4
oxxox
8
oxxox
and oxxoxoxxoxoxxox
.
Replacing x
at the and -th characters with o
makes oxxooooooooxxox
.
Now we have a length- contiguous substring consisting of o
, which is the longest possible.
30 1000000000 9982443530
oxoxooxoxoxooxoxooxxxoxxxooxox
19964887064