結果
| 問題 |
No.2738 CPC To F
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:51:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 693 bytes |
| コンパイル時間 | 154 ms |
| コンパイル使用メモリ | 82,184 KB |
| 実行使用メモリ | 93,552 KB |
| 最終ジャッジ日時 | 2025-06-12 19:52:08 |
| 合計ジャッジ時間 | 2,007 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / 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)
gew1fw