結果

問題 No.1368 サイクルの中に眠る門松列
ユーザー 👑 timitimi
提出日時 2021-03-05 11:41:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 116,480 KB
最終ジャッジ日時 2024-04-16 00:33:56
合計ジャッジ時間 4,314 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,224 KB
testcase_01 AC 44 ms
52,224 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 111 ms
113,792 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
for i in range(T):
  N=int(input())
  A=list(map(int, input().split()))
  B=A[1:]+A[:1]
  C=A[2:]+A[:2]
  a,b,c=0,0,0
  d=0
  for j in range(N-2):
    d-=1
    if A[j]!=A[j+1] and A[j+1]!=A[j+2] and A[j+2]!=A[j] and d<0:
      if min(A[j],A[j+1],A[j+2])==A[j+1] or max(A[j],A[j+1],A[j+2])==A[j+1]:
        a=max(a,A[j])
        d=2 
  d=0
  for j in range(N-2):
    d-=1
    if B[j]!=B[j+1] and B[j+1]!=B[j+2] and B[j+2]!=B[j] and d<0:
      if min(B[j],B[j+1],B[j+2])==B[j+1] or max(B[j],B[j+1],B[j+2])==B[j+1]:
        b=max(b,B[j])
        d=2
  d=0
  for j in range(N-2):
    d-=1
    if C[j]!=C[j+1] and C[j+1]!=C[j+2] and C[j+2]!=C[j] and d<0:
      if min(C[j],C[j+1],C[j+2])==C[j+1] or max(C[j],C[j+1],C[j+2])==C[j+1]:
        c=max(c,C[j])
        d=2
  print(max(a,b,c))
0