結果

問題 No.1188 レベルX門松列
ユーザー carrot46carrot46
提出日時 2020-08-22 13:59:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 1,795 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 170,368 KB
実行使用メモリ 7,732 KB
最終ジャッジ日時 2023-08-05 11:08:45
合計ジャッジ時間 3,612 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
6,992 KB
testcase_01 AC 64 ms
6,312 KB
testcase_02 AC 57 ms
5,944 KB
testcase_03 AC 77 ms
6,980 KB
testcase_04 AC 50 ms
7,716 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 20 ms
7,048 KB
testcase_07 AC 54 ms
7,660 KB
testcase_08 AC 54 ms
7,732 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 49 ms
5,368 KB
testcase_15 AC 84 ms
6,956 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 66 ms
6,316 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 62 ms
5,896 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <chrono>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}

void up(vec &a, vec &memo){
    vec left(0);
    rep(i,N){
        memo[i] = lower_bound(ALL(left), a[i]) - left.begin();
        auto ite = upper_bound(ALL(left), a[i]);
        if(ite == left.begin()){
            if(left.empty()) left.push_back(a[i]);
            else chmin(left[0], a[i]);
        }else{
            if(ite == left.end()){
                if(*left.rbegin() < a[i]) left.push_back(a[i]);
            }else{
                --ite;
                if(*ite < a[i]) left[(ite - left.begin()) + 1] = a[i];
            }
        }
    }
}

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    vec lu(N), ru(N), ld(N), rd(N);
    up(a, lu);
    reverse(ALL(a));
    up(a, ru);
    reverse(ALL(ru));

    rep(i, N) a[i] = -a[i];
    up(a, rd);
    reverse(ALL(rd));
    reverse(ALL(a));
    up(a, ld);
    ll ans = 0;
    rep(i,N) chmax(ans, max(min(lu[i], ru[i]), min(ld[i], rd[i])));
    /*
    rep(i,N) cout<<lu[i]<<" \n"[i == N - 1];
    rep(i,N) cout<<ru[i]<<" \n"[i == N - 1];
    rep(i,N) cout<<ld[i]<<" \n"[i == N - 1];
    rep(i,N) cout<<rd[i]<<" \n"[i == N - 1];
     */
    cout<<ans<<endl;
}
0