結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
|
提出日時 | 2023-05-01 08:12:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 1,000 ms |
コード長 | 766 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-11-20 08:59:51 |
合計ジャッジ時間 | 3,487 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
d = int(input()) s = '' for _ in range(2): s += input() C = [] x = d o = 0 for i in range(14): if s[i] == 'x': x += 1 if o > 0 and i != 0: C.append(o) o = 0 else: o += 1 if x > 0 or i == 0: C.append(x) x = 0 if i == 13: if x > 0: C.append(x + d) C.append(0) else: C.append(o) C.append(d) C.append(0) n = len(C) ans = 0 i = 0 for i in range(0, n, 2): if i == 0: x, o = C[i:i + 2] ans = max(ans, min(x, d) + o) else: o1, x, o2 = C[i - 1:i + 2] if x <= d: ans = max(ans, o1 + x + o2) else: ans = max(ans, o1 + d, o2 + d) print(ans)