結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:46:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,330 bytes |
コンパイル時間 | 232 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 54,352 KB |
最終ジャッジ日時 | 2025-06-12 18:46:16 |
合計ジャッジ時間 | 3,405 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 21 |
ソースコード
D = int(input()) s = input().strip() + input().strip() s = s[:14] # Ensure exactly 14 characters n = 14 left = [0] * n current = 0 for i in range(n): if s[i] == 'o': current += 1 else: current = 0 left[i] = current right = [0] * n current = 0 for i in reversed(range(n)): if s[i] == 'o': current += 1 else: current = 0 right[i] = current max_len = 0 if D == 0: max_len = max(left) else: # Check internal intervals for i in range(n): j = i + D - 1 if j >= n: continue # Check if all characters from i to j are 'x' all_x = True for k in range(i, j + 1): if s[k] != 'x': all_x = False break if not all_x: continue # Calculate possible extension prev_o = left[i - 1] if i > 0 else 0 next_o = right[j + 1] if j < n - 1 else 0 total = prev_o + D + next_o if total > max_len: max_len = total # Check front boundary (D days before the calendar) total_front = D + right[0] if total_front > max_len: max_len = total_front # Check back boundary (D days after the calendar) total_back = left[-1] + D if total_back > max_len: max_len = total_back print(max_len)