結果
問題 |
No.1368 サイクルの中に眠る門松列
|
ユーザー |
![]() |
提出日時 | 2021-03-23 15:36:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 798 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 82,124 KB |
実行使用メモリ | 101,812 KB |
最終ジャッジ日時 | 2024-11-25 07:23:23 |
合計ジャッジ時間 | 3,451 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 WA * 11 |
ソースコード
#!/usr/bin/env python3 #coding:utf-8 import math import string from sys import stdin # import numpy as np # from matplotlib import pyplot as plt def main(): read=stdin.readline #edit here! t=int(read()) while t>0: t-=1 n=int(read()) a=list(map(int,read().split())) check=lambda a,b,c:a!=b and b!=c and c!=a and (a<b>c or a>b<c) res=0 ans=0 i=0 while i<n-2: if check (a[i],a[i+1],a[i+2]): ans+=a[i] i+=3 else : i+=1 i=0 while i<n-2: if check(a[(i+1)%n],a[(i+2)%n],a[(i+3)%n]): res+=a[(i+1)%n] i+=3 else: i+=1 ans=max(ans,res) res=0 i=0 while i<n-2: if check(a[(i+2)%n],a[(i+3)%n],a[(i+4)%n]): res+=a[(i+2)%n] i+=3 else: i+=1 ans=max(ans,res) print(ans) if __name__ == '__main__': main()