結果

問題 No.1188 レベルX門松列
ユーザー kenskens
提出日時 2020-08-22 15:47:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 818 bytes
コンパイル時間 2,154 ms
コンパイル使用メモリ 197,644 KB
実行使用メモリ 6,896 KB
最終ジャッジ日時 2024-04-23 10:04:13
合計ジャッジ時間 3,885 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
6,896 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 79 ms
6,896 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 34 ms
6,772 KB
testcase_07 AC 69 ms
6,896 KB
testcase_08 AC 68 ms
6,896 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 83 ms
6,880 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
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+1);
  rep(i,l) {
    *lower_bound(dp.begin(),dp.end(),a[i]) = a[i];
    v[i+1] = lower_bound(dp.begin(),dp.end(),INF) - dp.begin();
  }
  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,(va[i]+vb[n-i]-1)/2);
    ans = max(ans,(vc[i]+vd[n-i]-1)/2);
  }
  cout << ans << endl;
  return 0;
}
0