結果

問題 No.1188 レベルX門松列
ユーザー O2MTO2MT
提出日時 2020-08-22 14:02:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,604 KB
最終ジャッジ日時 2024-04-23 08:27:54
合計ジャッジ時間 3,279 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
17,656 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 31 ms
10,624 KB
testcase_06 AC 117 ms
12,672 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 31 ms
10,752 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 31 ms
10,624 KB
testcase_21 AC 29 ms
10,624 KB
testcase_22 WA -
testcase_23 AC 30 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = min(lc,lr)
    if flg == 0:
      flg = 1
      lr = 0
    else:
      flg = 0
      lc = 0
X = min(lc,lr)
if p.count(1) == 0 or p.count(-1) == 0:
  print(0)
else:
  print(X+1)
0