結果
問題 | No.1188 レベルX門松列 |
ユーザー | rogi52 |
提出日時 | 2022-10-04 01:28:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,034 bytes |
コンパイル時間 | 1,981 ms |
コンパイル使用メモリ | 204,100 KB |
実行使用メモリ | 5,488 KB |
最終ジャッジ日時 | 2023-08-27 22:43:09 |
合計ジャッジ時間 | 3,677 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
5,344 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 21 ms
5,440 KB |
testcase_07 | AC | 48 ms
5,348 KB |
testcase_08 | AC | 48 ms
5,436 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 1 ms
4,376 KB |
testcase_21 | AC | 1 ms
4,376 KB |
testcase_22 | AC | 1 ms
4,376 KB |
testcase_23 | AC | 1 ms
4,376 KB |
ソースコード
#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; }