結果

問題 No.1368 サイクルの中に眠る門松列
ユーザー aaaaaaaaaa2230
提出日時 2021-01-29 22:41:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 419 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 112,588 KB
最終ジャッジ日時 2024-06-27 09:01:57
合計ジャッジ時間 4,024 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
    n = int(input())
    A = list(map(int,input().split()))
    dp = [0]*(n+5)
    ans = 0
    for j in range(3):
        a = A[j:]+A[:j]
        dp = [0]*(n+5)
        for i in range(n-2):
            x = a[i:i+3]
            if len(set(x)) == 3 and (min(x) == x[1] or max(x) == x[1]):
                dp[i+3] = max(dp[i+3],dp[i]+a[i])
        ans = max(ans,max(dp))
    print(ans)
0