結果
| 問題 |
No.1188 レベルX門松列
|
| コンテスト | |
| ユーザー |
auaua
|
| 提出日時 | 2020-08-22 14:37:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 2,000 ms |
| コード長 | 1,553 bytes |
| コンパイル時間 | 1,694 ms |
| コンパイル使用メモリ | 171,484 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-10-15 08:52:28 |
| 合計ジャッジ時間 | 3,382 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#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;
}
auaua