結果
| 問題 |
No.284 門松と魔法(2)
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:05:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 773 bytes |
| コンパイル時間 | 153 ms |
| コンパイル使用メモリ | 82,368 KB |
| 実行使用メモリ | 89,516 KB |
| 最終ジャッジ日時 | 2025-06-12 20:11:58 |
| 合計ジャッジ時間 | 2,948 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 WA * 15 |
ソースコード
n = int(input())
a = list(map(int, input().split()))
# Process the array to remove consecutive duplicates
processed = []
prev = None
for num in a:
if num != prev:
processed.append(num)
prev = num
m = len(processed)
if m < 3:
print(0)
else:
up = 1
down = 1
for i in range(1, m):
current = processed[i]
prev_num = processed[i-1]
if current > prev_num:
new_up = down + 1
new_down = down
elif current < prev_num:
new_down = up + 1
new_up = up
else:
# This case is handled by preprocessing, so it's redundant here
continue
up, down = new_up, new_down
max_len = max(up, down)
print(max_len if max_len >= 3 else 0)
gew1fw