No.204 Golden Week (2)
タグ : / 解いたユーザー数 253
作問者 :
Problem Statement
Apparently, it is Golden Week out there.
So here is a Golden Week-like problem.
You are given a calendar showing the weekdays ($x$) and holidays ($o$) over a period of $2$ weeks.
All days outside this $2$-week period are weekdays.
You are also given paid leave: the right to turn up to $D$ consecutive weekdays into holidays.
(It must not be split.)
Using this paid leave well, find the maximum possible length of a holiday streak (consecutive holidays).
The dates extend infinitely in both the past and the future.
Input
$D$
$C_{1}C_{2}....C_{7}$
$C_{8}C_{9}....C_{14}$
$0\le D \le 14$ ($D$ is an integer) is the number of days for which up to $D$ consecutive weekdays can be turned into holidays.
Each $C_{i}$ is the character $"x"$ or $"o"$. $"x"$ represents a weekday and $"o"$ represents a holiday.
$C_{1},C_{2}...,C_{N}$ are considered to be consecutive.
Output
Find the maximum length of a holiday streak (consecutive holidays).
Sample
Sample 1
Input
2 oxxoxxo ooooxxo
Output
8
This is the Golden Week of 2016.
By using the paid leave well, you can get 8 consecutive holidays.
(In reality, the following Sunday is also included, making 9 consecutive holidays.)
Sample 2
Input
5 ooxxxxx ooooooo
Output
14
You can take 14 days off.
Sample 3
Input
1 oxxxxxo xoxxxxo
Output
3
Note that the end of the first line and the beginning of the second line are connected.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。