結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー maguroguma
提出日時 2017-08-21 15:52:54
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 949 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-15 00:51:05
合計ジャッジ時間 2,998 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 11 WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

D = int(input())
C = input()
C += input()

#maru = batsu = 0
maru = 2
batsu = 0
weekday = True
cont_list = []
for c in C:
    if weekday and c=='o':
        maru += 1
    elif weekday and c=='x':
        cont_list.append(maru)
        batsu = 1
        weekday = False
    elif not weekday and c=='x':
        batsu += 1
    elif not weekday and c=='o':
        cont_list.append(batsu)
        maru = 1
        weekday = True
if weekday:
    cont_list.append(maru)
else:
    cont_list.append(batsu)

ans = 0
for i in range(1, len(cont_list), 2):
    holidays = cont_list[i]
    if D >= holidays:
        c_holidays = cont_list[i-1] + holidays
        if i+1<len(cont_list):
            c_holidays += cont_list[i+1]
        ans = max(ans, c_holidays)
    else:
        if i+1<len(cont_list):
            ans = max(ans, cont_list[i-1]+D, D+cont_list[i+1])
        else:
            ans = max(ans, cont_list[i-1]+D)

print(ans)
0