結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー tktk_snsn
提出日時 2021-03-16 00:10:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-07 12:49:09
合計ジャッジ時間 3,341 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 15 RE * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

def RunLengthEncoding(S):
    res = []
    N = len(S)
    i = 0
    while i < N:
        cnt = 1
        while i < N - 1 and S[i] == S[i + 1]:
            cnt += 1
            i += 1
        res.append((S[i], cnt))
        i += 1
    return res


D = int(input())
S = input() + input()
rle = RunLengthEncoding(S)
ans = 0
for i in range(len(rle)):
    if rle[i][0] == "o":
        ans = max(ans, rle[i][1])
    elif rle[i][1] <= D:
        L = rle[i][1]
        if i:
            L += rle[i - 1][1]
        if i + 1 < 14:
            L += rle[i + 1][1]
        ans = max(ans, L)

print(ans)
0