結果

問題 No.1188 レベルX門松列
ユーザー auauaauaua
提出日時 2020-08-22 14:37:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 1,553 bytes
コンパイル時間 1,626 ms
コンパイル使用メモリ 167,744 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-04-23 08:57:36
合計ジャッジ時間 3,478 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
8,064 KB
testcase_01 AC 53 ms
7,040 KB
testcase_02 AC 49 ms
6,940 KB
testcase_03 AC 64 ms
7,936 KB
testcase_04 AC 64 ms
7,936 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 27 ms
7,936 KB
testcase_07 AC 60 ms
8,064 KB
testcase_08 AC 60 ms
7,936 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 7 ms
6,944 KB
testcase_12 AC 6 ms
6,940 KB
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 43 ms
6,940 KB
testcase_15 AC 69 ms
8,064 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 54 ms
7,168 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 51 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=998244353;
const int MAX=1000010;



signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>LIS1(n);
    vector<ll>LDS1(n);
    vector<ll>LIS2(n);
    vector<ll>LDS2(n);
    vector<ll>d(n,inf);
    rep(i,n){
        *lower_bound(all(d),a[i])=a[i];
        ll s=lower_bound(all(d),inf)-d.begin();
        LIS1[i]=s;
    }
    rep(i,n)d[i]=inf;
    rep(i,n){
        *lower_bound(all(d),-a[i])=-a[i];
        ll s=lower_bound(all(d),inf)-d.begin();
        LDS1[i]=s;
    }
    rep(i,n)d[i]=inf;
    reverse(all(a));
    rep(i,n){
        *lower_bound(all(d),a[i])=a[i];
        ll s=lower_bound(all(d),inf)-d.begin();
        LIS2[i]=s;
    }
    reverse(all(LIS2));
    rep(i,n)d[i]=inf;
    rep(i,n){
        *lower_bound(all(d),-a[i])=-a[i];
        ll s=lower_bound(all(d),inf)-d.begin();
        LDS2[i]=s;
    }
    reverse(all(LDS2));
    ll ans=0;
    rep(i,n){
        ans=max(ans,min(LIS1[i]-1,LIS2[i]-1));
        ans=max(ans,min(LDS1[i]-1,LDS2[i]-1));
    }
    cout<<ans<<endl;
}
0