結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー amylase_pepsin
提出日時 2015-06-13 01:33:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-10-13 13:21:09
合計ジャッジ時間 3,223 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

__author__ = 'amylase'

def solve(d, s):
    """
    solution for yukicoder No.204

    >>> solve(2, 'oxxoxxoooooxxo')
    8

    >>> solve(5, 'ooxxxxxooooooo')
    14

    >>> solve(1, 'oxxxxxoxoxxxxo')
    3

    :param d: maximum continuous PTO
    :param s: calendar string
    :return: longest continuous holiday
    """
    n = len(s)

    answer = 0
    for i in range(n):
        j = i
        while j < n and s[j] == 'o' :
            j += 1

        used = 0
        while j < n and s[j] == 'x' and used < d:
            j += 1
            used += 1

        while j < n and s[j] == 'o' :
            j += 1

        answer = max(j - i, answer)

    return answer


if __name__ == '__main__':
    d = int(input())
    s = input() + input()
    print(solve(d, s))
0