結果
| 問題 | 
                            No.1188 レベルX門松列
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-08-22 14:07:50 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 547 bytes | 
| コンパイル時間 | 222 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 21,360 KB | 
| 最終ジャッジ日時 | 2024-10-15 08:23:31 | 
| 合計ジャッジ時間 | 3,615 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 5 WA * 16 | 
ソースコード
N = int(input())
A = list(map(int,input().split()))
X = 0
flg = 0
p = [0]*N
if N <= 2:
  print(0)
  exit()
for i in range(1,N):
  if A[i-1] < A[i]:
    p[i] = 1
  elif A[i-1] > A[i]:
    p[i] = -1
p[0] = p[1]
lc,lr = 0,0
for i in range(1,N):
  if p[i] == p[i-1] and flg == 0:
    lc += 1
  elif p[i] == p[i-1] and flg == 1:
    lr += 1
  else:
    X = max(X,min(lc,lr)+1)
    if flg == 0:
      flg = 1
      lr = 0
    else:
      flg = 0
      lc = 0
X = max(X,min(lc,lr)+1)
if p.count(1) == 0 or p.count(-1) == 0:
  print(0)
else:
  print(X)