結果

問題 No.1188 レベルX門松列
ユーザー kenskens
提出日時 2020-08-22 16:03:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 817 bytes
コンパイル時間 2,226 ms
コンパイル使用メモリ 198,584 KB
実行使用メモリ 7,024 KB
最終ジャッジ日時 2024-04-23 10:17:37
合計ジャッジ時間 4,039 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
7,024 KB
testcase_01 AC 67 ms
6,172 KB
testcase_02 AC 60 ms
5,884 KB
testcase_03 AC 83 ms
6,768 KB
testcase_04 AC 71 ms
6,944 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 31 ms
7,024 KB
testcase_07 AC 70 ms
6,768 KB
testcase_08 AC 70 ms
6,944 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 8 ms
5,376 KB
testcase_12 AC 7 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 53 ms
5,452 KB
testcase_15 AC 90 ms
6,748 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 70 ms
6,068 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 66 ms
5,996 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

vector<int> LIS(vector<int> &a) {
  const int INF = 2e9;
  int l = a.size();
  vector<int> dp(l,INF), v(l);
  rep(i,l) {
    v[i] = lower_bound(dp.begin(),dp.end(),a[i]) - dp.begin();
    *lower_bound(dp.begin(),dp.end(),a[i]) = a[i];
  }
  return v;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n), d(n);
  rep(i,n) {
    cin >> a[i];
    b[n-1-i] = a[i];
    c[i] = -a[i];
    d[n-1-i] = -a[i];
  }
  vector<int> va = LIS(a);
  vector<int> vb = LIS(b);
  vector<int> vc = LIS(c);
  vector<int> vd = LIS(d);
  int ans = 0;
  for(int i = 1; i < n-1; i++) {
    ans = max(ans,min(va[i],vb[n-i-1]));
    ans = max(ans,min(vc[i],vd[n-i-1]));
  }
  cout << ans << endl;
  return 0;
}
0