結果

問題 No.1368 サイクルの中に眠る門松列
ユーザー kohei2019kohei2019
提出日時 2022-07-18 19:09:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 759 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,884 KB
実行使用メモリ 109,416 KB
最終ジャッジ日時 2023-09-13 09:20:11
合計ジャッジ時間 4,922 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,168 KB
testcase_01 AC 71 ms
71,460 KB
testcase_02 AC 230 ms
79,012 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 159 ms
109,212 KB
testcase_06 WA -
testcase_07 AC 133 ms
109,416 KB
testcase_08 AC 157 ms
109,092 KB
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())
def iskadomatu(ll):
    if ll[0] == ll[1] or ll[1] == ll[2] or ll[2] == ll[0]:
        return False
    if (ll[0] > ll[1] and ll[1] < ll[2]) or (ll[0] < ll[1] and ll[1] > ll[2]):
        return True
    return False

lsans = []
for i in range(T):
    N = int(input())
    lsA = list(map(int,input().split()))
    ans = 0
    for j in range(3):
        dp = [0]*(N)
        ruimax = 0
        for k in range(N-2):
            if k-3 < 0 and iskadomatu(lsA[k:k+3]):
                dp[k] += lsA[k]
            elif iskadomatu(lsA[k:k+3]):
                ruimax = max(ruimax,dp[k-3])
                dp[k] += lsA[k] + ruimax
        ans = max(ans,max(dp))
        lsA = [lsA[-1]] + lsA[:-1]
    lsans.append(ans)
print(*lsans,sep='\n')
        
0