結果
| 問題 |
No.1827 最長部分スーパーリッチ門松列列
|
| コンテスト | |
| ユーザー |
ytft
|
| 提出日時 | 2022-02-16 20:27:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 176 ms / 2,000 ms |
| コード長 | 495 bytes |
| コンパイル時間 | 1,748 ms |
| コンパイル使用メモリ | 166,480 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2024-06-29 07:18:57 |
| 合計ジャッジ時間 | 6,849 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 24 |
ソースコード
#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();
}
}
ytft