結果
| 問題 | 
                            No.204 ゴールデン・ウィーク(2)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kbys
                         | 
                    
| 提出日時 | 2020-07-19 20:02:20 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,135 bytes | 
| コンパイル時間 | 136 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-12-16 09:33:05 | 
| 合計ジャッジ時間 | 3,078 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 WA * 27 | 
ソースコード
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)
            
            
            
        
            
kbys