結果
| 問題 |
No.1368 サイクルの中に眠る門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-29 22:32:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,031 bytes |
| コンパイル時間 | 2,134 ms |
| コンパイル使用メモリ | 195,356 KB |
| 最終ジャッジ日時 | 2025-01-18 09:31:50 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 11 |
ソースコード
/**
* author: shu8Cream
* created: 29.01.2021 20:56:35
**/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
bool isKM(vector<ll> a){
if(a[0]==a[1] || a[1]==a[2] || a[2]==a[0]) return false;
if(max({a[0],a[1],a[2]})==a[1] || min({a[0],a[1],a[2]})==a[1]){
return true;
}
return false;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
cin >> t;
while(t--){
int n; cin >> n;
vector<ll> a(n+2);
rep(i,n) cin >> a[i];
a[n]=a[0]; a[n+1]=a[1];
ll ans = 0;
rep(i,3){
ll tmp = 0;
for(int j=i; j<n; j+=3){
vector<ll> b(3);
b[0]=a[j]; b[1]=a[j+1], b[2]=a[j+2];
if(isKM(b)) tmp+=a[j];
}
ans=max(ans, tmp);
}
cout << ans << endl;
}
}