問題一覧 > 通常問題

No.204 Golden Week (2)

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 253
作問者 : yuki2006
お気に入りにしたユーザー ProblemId : 490 / 自分の提出
問題文最終更新日: 2020-03-15 18:41:58
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
yukicoder contest 103 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。