結果
問題 | No.1368 サイクルの中に眠る門松列 |
ユーザー |
![]() |
提出日時 | 2021-01-29 21:40:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,054 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 82,252 KB |
実行使用メモリ | 108,192 KB |
最終ジャッジ日時 | 2024-06-27 07:52:03 |
合計ジャッジ時間 | 2,950 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 WA * 5 |
ソースコード
import sys;input = lambda: sys.stdin.readline().rstrip()#import heapq#from collections import deque#import numpy as np#from collections import Counter as cnt#from collections import defaultdict as ddc#from math import factorial as fct#from math import gcd#from bisect import bisect_left as bsl#from bisect import bisect_right as bsr#from itertools import accumulate as acc#from itertools import combinations as cmb#from itertools import permutations as pmt#from itertools import product as prd#from functools import reduce as red#import sys#sys.setrecursionlimit(10**9) #再帰を多く使う(デフォルトは1000)for _ in range(int(input())):n = int(input())A = list(map(int,input().split()))A += A[:2]K = [0]*nfor i in range(n):S = A[i:i+3]if len(set(S)) == 3 and S[1] in {min(S), max(S)}:K[i] = S[0]DP = [0]*nDP[0] = K[0]DP[1] = max(K[:2])DP[2] = max(K[:3])for i in range(3, n):DP[i] = max(DP[i-1], DP[i-2], DP[i-3]+K[i])print(DP[-1])