結果

問題 No.1368 サイクルの中に眠る門松列
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-01-29 22:41:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 419 bytes
コンパイル時間 1,278 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 114,264 KB
最終ジャッジ日時 2023-09-09 16:15:17
合計ジャッジ時間 5,055 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,428 KB
testcase_01 AC 71 ms
71,260 KB
testcase_02 AC 260 ms
80,164 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 241 ms
113,664 KB
testcase_06 WA -
testcase_07 AC 169 ms
114,264 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 _ 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