結果

問題 No.1368 サイクルの中に眠る門松列
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-12 09:11:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 417 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 86,676 KB
実行使用メモリ 118,748 KB
最終ジャッジ日時 2023-09-26 08:36:36
合計ジャッジ時間 5,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,276 KB
testcase_01 AC 71 ms
71,252 KB
testcase_02 AC 189 ms
79,052 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 149 ms
112,308 KB
testcase_06 WA -
testcase_07 AC 126 ms
118,748 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())
ans=[]
for _ in range(t):
  n=int(input())
  a_=list(map(int,input().split()))
  ansi=0
  for idx in range(3):# スタート位置
    dp=[0]*(n+1)
    a=a_[idx:]+a_[:idx]
    for i in range(2,n):
      if a[i-2]!=a[i-1]!=a[i] and a[i-2]!=a[i] and (a[i-2]<a[i-1]>a[i] or a[i-2]>a[i-1]<a[i]):
        dp[i+1]=max(dp[i+1],dp[i-2]+a[i-2])
    ansi=max(ansi,max(dp))
  ans.append(ansi)
print(*ans,sep='\n')
0