結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 👑 rin204
提出日時 2022-01-20 08:22:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 1,000 ms
コード長 486 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-11-23 14:21:50
合計ジャッジ時間 3,440 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

d = int(input())
C = "o" + "x" * (d + 1) + input() + input() + "x" * (d + 1) + "o"
if C.count("o") == 2:
    print(d)
    exit()
bef = "o"
lst = []
cnt = 0
for c in C:
    if c != bef:
        lst.append(cnt)
        cnt = 1
        bef = c
    else:
        cnt += 1

lst.append(cnt)


l = len(lst)
ans = 0
for i in range(1, l, 2):
    if lst[i] <= d:
        ans = max(ans, lst[i - 1] + lst[i] + lst[i + 1])
    else:
        ans = max(ans, max(lst[i - 1], lst[i + 1]) + d)
print(ans)
0