結果
問題 |
No.284 門松と魔法(2)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:04:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 758 bytes |
コンパイル時間 | 178 ms |
コンパイル使用メモリ | 81,912 KB |
実行使用メモリ | 89,300 KB |
最終ジャッジ日時 | 2025-06-12 20:10:44 |
合計ジャッジ時間 | 3,351 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 WA * 15 |
ソースコード
n = int(input()) A = list(map(int, input().split())) # Remove adjacent duplicates B = [] for num in A: if not B or num != B[-1]: B.append(num) m = len(B) if m < 3: print(0) else: inc = 1 # length of the longest zigzag ending with an increase dec = 1 # length of the longest zigzag ending with a decrease for i in range(1, m): if B[i] > B[i-1]: new_inc = dec + 1 new_dec = dec elif B[i] < B[i-1]: new_dec = inc + 1 new_inc = inc else: # This case is redundant since B has no duplicates new_inc = inc new_dec = dec inc, dec = new_inc, new_dec max_len = max(inc, dec) print(max_len if max_len >= 3 else 0)