結果
問題 |
No.2738 CPC To F
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:49:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 693 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 82,188 KB |
実行使用メモリ | 93,512 KB |
最終ジャッジ日時 | 2025-06-12 14:52:42 |
合計ジャッジ時間 | 2,410 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 WA * 17 |
ソースコード
n = int(input()) s = input().strip() original_count = 0 for i in range(len(s) - 4): if s[i] == 'C' and s[i+1] == 'P' and s[i+2] == 'C' and s[i+3] == 'T' and s[i+4] == 'F': original_count += 1 candidates = [] for j in range(len(s) - 2): if s[j] == 'C' and s[j+1] == 'P' and s[j+2] == 'C': if j >= 4: if s[j-4] == 'C' and s[j-3] == 'P' and s[j-2] == 'C' and s[j-1] == 'T': candidates.append((j, j + 2)) # Sort intervals by their end points candidates.sort(key=lambda x: x[1]) new_count = 0 prev_end = -1 for start, end in candidates: if start > prev_end: new_count += 1 prev_end = end print(original_count + new_count)