結果

問題 No.1188 レベルX門松列
ユーザー shiomusubi496shiomusubi496
提出日時 2020-08-22 17:56:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 1,036 bytes
コンパイル時間 1,709 ms
コンパイル使用メモリ 168,384 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-23 11:49:09
合計ジャッジ時間 3,332 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
10,240 KB
testcase_01 AC 54 ms
9,088 KB
testcase_02 AC 48 ms
8,576 KB
testcase_03 AC 65 ms
10,240 KB
testcase_04 AC 59 ms
10,240 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 28 ms
10,240 KB
testcase_07 AC 54 ms
10,240 KB
testcase_08 AC 54 ms
10,240 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 43 ms
7,680 KB
testcase_15 AC 73 ms
10,240 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 57 ms
8,832 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 53 ms
8,320 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF=10000000000;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)cin>>i;
  vector<int> B(N+2),C(N+2),D(N+1,INF),E(N+1,INF),F(N+1,INF),G(N+1,INF),H(N+2),I(N+2);
  D[0]=-INF,E[0]=-INF,F[0]=-INF,G[0]=-INF;
  for(int i=0;i<N;i++){
    B[i+1]=B[i];
    int it=lower_bound(D.begin(),D.end(),A[i])-D.begin();
    if(D[it]==INF)B[i+1]++;
    D[it]=A[i];
  }
  for(int i=N;i>0;i--){
    C[i]=C[i+1];
    int it=lower_bound(E.begin(),E.end(),A[i-1])-E.begin();
    if(E[it]==INF)C[i]++;
    E[it]=A[i-1];
  }
  for(int i=0;i<N;i++){
    H[i+1]=H[i];
    int it=lower_bound(F.begin(),F.end(),-A[i])-F.begin();
    if(F[it]==INF)H[i+1]++;
    F[it]=-A[i];
  }
  for(int i=N;i>0;i--){
    I[i]=I[i+1];
    int it=lower_bound(G.begin(),G.end(),-A[i-1])-G.begin();
    if(G[it]==INF)I[i]++;
    G[it]=-A[i-1];
  }
  int ans=0;
  for(int i=1;i<=N;i++)ans=max(ans,min(B[i],C[i]));
  for(int i=1;i<=N;i++)ans=max(ans,min(H[i],I[i]));
  cout<<ans-1<<endl;
}
0