結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー kbys
提出日時 2020-07-19 19:55:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,135 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-12-16 09:17:36
合計ジャッジ時間 3,534 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

d = int(input())
a = list(input())
b = list(input())
week = a+b

schedule = []
now = 0
for w in week:
    if w == "o":
        if now > 0:
            now += 1
        else:
            schedule.append(now)
            now = 1
    else:
        if now < 0:
            now -= 1
        else:
            schedule.append(now)
            now = -1
schedule.append(now)
schedule = schedule[1:]

ans = 0
for i,v in enumerate(schedule):
    if v > 0:
        continue
    else:
        if abs(v) <= d:
            tmp = abs(v)
            try:
                tmp += schedule[i-1]
            except IndexError:
                continue
            try:
                tmp += schedule[i+1]
            except IndexError:
                continue
            ans = max(ans, tmp)
        else:
            tmp = d
            try:
                tmp += schedule[i-1]
            except IndexError:
                continue
            ans = max(ans, tmp)
            
            tmp = d
            try:
                tmp += schedule[i+1]
            except IndexError:
                continue
            ans = max(ans, tmp)
print(ans)
0