結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー fmhr
提出日時 2015-05-08 23:35:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-13 11:55:00
合計ジャッジ時間 2,846 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding:utf-8

D = int(input())
C = 'xxxxxxxxxxxxxxx' + input()
C = C + input() + 'xxxxxxxxxxxxxxxxx'
ans = [0]
for i in range(len(C)+1):
    for j in range(i, len(C)+1):
        e = C[i:j]
        # xの連続チェック
        flag = 0
        for f in range(len(e)):
            if e[f-1] == 'x' and e[f] == 'o':
                flag = 1
            if e[f-1] == 'o' and e[f] == 'x' and flag == 1:
                flag = 2
                break
        # xの数
        if flag != 2:
            for k in range(len(e)):
                if D > 0:
                    if 1 <= e.count('x') <= D:
                        ans.append(len(e))
                else:
                    if e.count('x') <= D:
                        ans.append(len(e))

print(max(ans))
0