結果

問題 No.1827 最長部分スーパーリッチ門松列列
ユーザー ytftytft
提出日時 2022-02-16 20:27:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 165,156 KB
実行使用メモリ 7,392 KB
最終ジャッジ日時 2023-09-11 17:14:38
合計ジャッジ時間 7,578 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,504 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 39 ms
4,376 KB
testcase_05 AC 40 ms
4,376 KB
testcase_06 AC 39 ms
4,380 KB
testcase_07 AC 141 ms
7,196 KB
testcase_08 AC 141 ms
7,244 KB
testcase_09 AC 140 ms
7,308 KB
testcase_10 AC 141 ms
7,240 KB
testcase_11 AC 140 ms
7,240 KB
testcase_12 AC 141 ms
7,336 KB
testcase_13 AC 141 ms
7,392 KB
testcase_14 AC 140 ms
7,372 KB
testcase_15 AC 141 ms
7,196 KB
testcase_16 AC 141 ms
7,212 KB
testcase_17 AC 158 ms
7,252 KB
testcase_18 AC 158 ms
7,212 KB
testcase_19 AC 141 ms
7,296 KB
testcase_20 AC 141 ms
7,224 KB
testcase_21 AC 142 ms
7,208 KB
testcase_22 AC 141 ms
7,200 KB
testcase_23 AC 141 ms
7,392 KB
testcase_24 AC 142 ms
7,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int N,input,cur=1,ans=1;
    cin>>N;
    int P[N],memo[N+2];
    fill(memo+1,memo+N+1,1);
    memo[0]=0;
    memo[N+1]=0;
    for(int i=1;i<=N;++i){
        cin>>input;
        P[input-1]=i;
    }
    for(int i=N-1;i>=0;--i){
        memo[P[i]]=-1;
        cur+=memo[P[i]+1]+memo[P[i]-1];
        ans=max(cur,ans);
    }
    cout<<ans<<endl;
}


int main(){
    int T;
    cin>>T;
    for(int i=0;i<T;++i){
        solve();
    }
}
0