結果

問題 No.1188 レベルX門松列
ユーザー akaneakane
提出日時 2020-08-22 17:42:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 950 bytes
コンパイル時間 2,355 ms
コンパイル使用メモリ 195,700 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-23 11:32:45
合計ジャッジ時間 6,233 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
10,624 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 9 ms
5,376 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];

    int ans=0;
    // 山
    for(int i=1; i<N-1; i++){
        int ln=0, rn=0;
        int l=i-1, r=i+1, il=i, ir=i;
        while(l>=0 && A[l]<A[il]){
            l--; il--;
            ln++;
        }

        while(r<N && A[ir]>A[r]){
            ir++; r++;
            rn++;
        }
        int mlr = min(ln,rn);
        ans = max(ans, mlr);
    }

    // 谷
    for(int i=1; i<N-1; i++){
        int ln=0, rn=0;
        int l=i-1, r=i+1, il=i, ir=i;
        while(l>=0 && A[l]>A[il]){
            l--; il--;
            ln++;
        }

        while(r<N && A[ir]<A[r]){
            ir++; r++;
            rn++;
        }
        int mlr = min(ln,rn);
        ans = max(ans, mlr);
    }

    cout << ans << endl;

}
0