結果

問題 No.1368 サイクルの中に眠る門松列
ユーザー shu8Creamshu8Cream
提出日時 2021-01-29 22:30:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,007 bytes
コンパイル時間 2,707 ms
コンパイル使用メモリ 200,772 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-09 16:01:31
合計ジャッジ時間 3,408 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 35 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 28 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 28 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
*    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(vi 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;
        vi 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){
                vi 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;
    }
}
0