結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,584 KB
testcase_01 AC 71 ms
71,448 KB
testcase_02 AC 244 ms
79,716 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 180 ms
109,192 KB
testcase_06 WA -
testcase_07 AC 146 ms
109,600 KB
testcase_08 AC 171 ms
109,148 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(6):
        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
            else:
                dp[k] = ruimax
        #print(dp)
        ans = max(ans,max(dp))
        lsA = [lsA[-1]] + lsA[:-1]
    lsans.append(ans)
print(*lsans,sep='\n')
0