結果
問題 |
No.1188 レベルX門松列
|
ユーザー |
|
提出日時 | 2022-10-04 01:28:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,034 bytes |
コンパイル時間 | 1,973 ms |
コンパイル使用メモリ | 197,728 KB |
最終ジャッジ日時 | 2025-02-07 21:08:39 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 14 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector<int> A(N); rep(i,N) cin >> A[i]; auto f = [N](vector<int> A) { auto LIS = [N](vector<int> A) { int INF = numeric_limits<int>::max(); vector<int> dp1(N, INF), dp2(N, 0); rep(i,N) { auto it = lower_bound(dp1.begin(), dp1.end(), A[i]); *it = A[i]; dp2[i] = lower_bound(dp1.begin(), dp1.end(), INF) - dp1.begin(); } return dp2; }; vector<int> L = LIS(A); reverse(A.begin(), A.end()); vector<int> R = LIS(A); reverse(A.begin(), A.end()); int ans = 0; rep(i,N) ans = max(ans, min(L[i], R[i]) - 1); return ans; }; int ans = 0; rep(_,2) { ans = max(ans, f(A)); rep(i,N) A[i] *= -1; } cout << ans << endl; }