結果
問題 | No.1188 レベルX門松列 |
ユーザー | ate |
提出日時 | 2020-08-22 14:48:55 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,345 bytes |
コンパイル時間 | 2,167 ms |
コンパイル使用メモリ | 206,512 KB |
実行使用メモリ | 8,092 KB |
最終ジャッジ日時 | 2024-10-15 09:08:43 |
合計ジャッジ時間 | 3,809 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 52 ms
7,148 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 55 ms
7,936 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | WA | - |
testcase_07 | AC | 51 ms
7,936 KB |
testcase_08 | AC | 54 ms
8,088 KB |
testcase_09 | AC | 1 ms
6,816 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 6 ms
6,820 KB |
testcase_13 | AC | 6 ms
6,820 KB |
testcase_14 | WA | - |
testcase_15 | AC | 70 ms
7,920 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
6,816 KB |
testcase_21 | AC | 1 ms
6,816 KB |
testcase_22 | AC | 2 ms
6,816 KB |
testcase_23 | AC | 2 ms
6,816 KB |
ソースコード
#if loc||local #define _GLIBCXX_DEBUG #endif #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<(n);++i) using ll = int_fast64_t; using pll = pair<ll,ll>; constexpr ll INF = 1LL<<60; constexpr ll MOD = 1e9+7; template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;} template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;} #if loc||local template<class T>void dump(T&& t){cerr<<t<<endl;} template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);} #else void dump(){} template<class T,class... Ts> void dump(T&& h, Ts&&... t){} #endif template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;} template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;} template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;} template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;} template<class T>vector<T> vec(size_t a){return vector<T>(a);} template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));} ll LIS(const vector<ll>& v){ ll n=((ll)v.size()); constexpr ll INF = (1LL<<60); vector<ll> lis(n+1,INF); lis[0]=-INF; for(ll i=0;i<n;++i){ auto itr = lower_bound(lis.begin(),lis.end(),v[i]); *itr=min(*itr,v[i]); } ll len=0; for(ll i=1;i<=n;++i){ if(lis[i]!=INF)len=i; } return len; } signed main(){ ll n; cin>>n; vector<ll> a(n); cin>>a; vector<ll> lef_inc(n),rig_inc(n); vector<ll> lef_dec(n),rig_dec(n); { vector<ll> lis(n+1,INF); lis[0] = 0; ll len = 0; for(int i=0;i<n;++i){ auto itr = lower_bound(begin(lis),end(lis),a[i]); ll val = *itr; *itr = min<ll>(val,a[i]); if(lis[len+1]!=INF){ len++; } lef_inc[i] = len; } dump(lef_inc); } { vector<ll> lis(n+1,INF); lis[0] = 0; reverse(begin(a),end(a)); ll len = 0; for(int i=0;i<n;++i){ auto itr = lower_bound(begin(lis),end(lis),a[i]); ll val = *itr; *itr = min<ll>(val,a[i]); if(lis[len+1]!=INF){ len++; } rig_inc[i] = len; } reverse(begin(rig_inc),end(rig_inc)); reverse(begin(a),end(a)); dump(rig_inc); } { vector<ll> lis(n+1,-INF); lis[0] = INF; ll len = 0; for(int i=0;i<n;++i){ auto itr = lower_bound(begin(lis),end(lis),a[i],greater<>()); ll val = *itr; *itr = max<ll>(val,a[i]); if(lis[len+1]!=-INF)len++; lef_dec[i] = len; } dump(lef_dec); } { vector<ll> lis(n+1,-INF); lis[0] = INF; ll len = 0; reverse(begin(a),end(a)); for(int i=0;i<n;++i){ auto itr = lower_bound(begin(lis),end(lis),a[i],greater<>()); ll val = *itr; *itr = max<ll>(val,a[i]); if(lis[len+1]!=-INF)len++; rig_dec[i] = len; } reverse(begin(rig_dec),end(rig_dec)); reverse(begin(a),end(a)); dump(rig_dec); } ll ans = 0; for(int i=1;i+1<n;++i){ ll ushi = min(lef_inc[i-1],rig_inc[i+1]); ll tapu = min(lef_dec[i-1],rig_dec[i+1]); ll nichia = max(ushi,tapu); chmax(ans,nichia); } cout<<(ans)<<endl; }