結果
| 問題 |
No.1368 サイクルの中に眠る門松列
|
| コンテスト | |
| ユーザー |
tanimani364
|
| 提出日時 | 2021-03-23 15:41:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 749 bytes |
| コンパイル時間 | 163 ms |
| コンパイル使用メモリ | 82,292 KB |
| 実行使用メモリ | 101,580 KB |
| 最終ジャッジ日時 | 2024-11-25 07:27:02 |
| 合計ジャッジ時間 | 3,485 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 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 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 ans=max(ans,res) print(ans) if __name__ == '__main__': main()
tanimani364