結果

問題 No.1368 サイクルの中に眠る門松列
ユーザー 👑 timitimi
提出日時 2021-03-05 11:58:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 784 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 30,784 KB
最終ジャッジ日時 2024-04-16 00:48:43
合計ジャッジ時間 10,034 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 33 ms
10,880 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 716 ms
30,652 KB
testcase_06 AC 752 ms
30,784 KB
testcase_07 AC 309 ms
30,780 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()))
  A=A+A
  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+=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+=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+=C[j]
        d=2
  print(max(a,b,c))
0