結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 18:46:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,860 bytes |
コンパイル時間 | 358 ms |
コンパイル使用メモリ | 82,764 KB |
実行使用メモリ | 54,604 KB |
最終ジャッジ日時 | 2025-06-12 18:46:54 |
合計ジャッジ時間 | 3,211 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 24 |
ソースコード
def main(): import sys D = int(sys.stdin.readline()) c1 = sys.stdin.readline().strip() c2 = sys.stdin.readline().strip() s = c1 + c2 # 14 characters # Split into intervals intervals = [] if not s: intervals = [] else: current_char = s[0] count = 1 for c in s[1:]: if c == current_char: count += 1 else: intervals.append({'type': current_char, 'length': count}) current_char = c count = 1 intervals.append({'type': current_char, 'length': count}) # Add virtual x intervals at both ends virtual_front = {'type': 'x', 'length': float('inf')} virtual_back = {'type': 'x', 'length': float('inf')} intervals = [virtual_front] + intervals + [virtual_back] max_len = 0 # Check each x interval for i in range(len(intervals)): interval = intervals[i] if interval['type'] != 'x': continue # Get previous and next intervals prev_interval = intervals[i-1] if i > 0 else None next_interval = intervals[i+1] if i+1 < len(intervals) else None prev_o = prev_interval['length'] if prev_interval and prev_interval['type'] == 'o' else 0 next_o = next_interval['length'] if next_interval and next_interval['type'] == 'o' else 0 l = interval['length'] d = min(D, l) current_max = prev_o + d + next_o if current_max > max_len: max_len = current_max # Also check the original maximum o interval original_max = 0 for interval in intervals: if interval['type'] == 'o' and interval['length'] > original_max: original_max = interval['length'] max_len = max(max_len, original_max) print(max_len) if __name__ == "__main__": main()