結果
| 問題 |
No.1368 サイクルの中に眠る門松列
|
| コンテスト | |
| ユーザー |
timi
|
| 提出日時 | 2021-03-05 11:58:58 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 784 bytes |
| コンパイル時間 | 85 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 31,808 KB |
| 最終ジャッジ日時 | 2024-10-06 09:04:44 |
| 合計ジャッジ時間 | 9,237 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 11 |
ソースコード
T=int(input())
for i in range(T):
N=int(input())
A=list(map(int, input().split()))
A=A+A
B=A[1:]+A[:1]
C=A[2:]+A[:2]
a,b,c=0,0,0
d=0
for j in range(N-2):
d-=1
if A[j]!=A[j+1] and A[j+1]!=A[j+2] and A[j+2]!=A[j] and d<0:
if min(A[j],A[j+1],A[j+2])==A[j+1] or max(A[j],A[j+1],A[j+2])==A[j+1]:
a+=A[j]
d=2
d=0
for j in range(N-2):
d-=1
if B[j]!=B[j+1] and B[j+1]!=B[j+2] and B[j+2]!=B[j] and d<0:
if min(B[j],B[j+1],B[j+2])==B[j+1] or max(B[j],B[j+1],B[j+2])==B[j+1]:
b+=B[j]
d=2
d=0
for j in range(N-2):
d-=1
if C[j]!=C[j+1] and C[j+1]!=C[j+2] and C[j+2]!=C[j] and d<0:
if min(C[j],C[j+1],C[j+2])==C[j+1] or max(C[j],C[j+1],C[j+2])==C[j+1]:
c+=C[j]
d=2
print(max(a,b,c))
timi