結果

問題 No.711 競技レーティング単調増加
ユーザー 0w10w1
提出日時 2018-10-30 16:07:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,635 bytes
コンパイル時間 3,134 ms
コンパイル使用メモリ 209,272 KB
実行使用メモリ 9,672 KB
最終ジャッジ日時 2023-08-12 10:27:51
合計ジャッジ時間 6,089 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 33 ms
8,068 KB
testcase_19 AC 32 ms
7,836 KB
testcase_20 AC 33 ms
8,144 KB
testcase_21 AC 35 ms
8,368 KB
testcase_22 AC 32 ms
8,304 KB
testcase_23 AC 36 ms
8,428 KB
testcase_24 AC 36 ms
8,400 KB
testcase_25 AC 31 ms
7,496 KB
testcase_26 AC 33 ms
7,916 KB
testcase_27 AC 31 ms
7,488 KB
testcase_28 AC 22 ms
7,244 KB
testcase_29 AC 26 ms
7,700 KB
testcase_30 AC 35 ms
8,752 KB
testcase_31 AC 40 ms
8,912 KB
testcase_32 AC 43 ms
9,080 KB
testcase_33 AC 42 ms
9,228 KB
testcase_34 AC 39 ms
9,004 KB
testcase_35 AC 42 ms
9,672 KB
testcase_36 AC 21 ms
7,684 KB
testcase_37 AC 35 ms
9,120 KB
testcase_38 AC 28 ms
8,724 KB
testcase_39 AC 15 ms
5,732 KB
testcase_40 AC 23 ms
6,752 KB
testcase_41 AC 2 ms
4,384 KB
testcase_42 AC 21 ms
6,276 KB
testcase_43 AC 30 ms
8,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template <typename T>
class Array : public vector<T> {
 public:
  using vector<T>::vector;
  using vector<T>::begin;
  using vector<T>::end;
  using vector<T>::push_back;
  template <typename R>
  Array<R> map(function<R(T)> f) {
    Array<R> res(end() - begin());
    for (auto it = begin(); it != end(); ++it) res[it - begin()] = f(*it);
    return res;
  }
  Array<T> select(function<bool(T)> f) {
    Array<T> res;
    for (auto it = begin(); it != end(); ++it)
      if (f(*it)) res.push_back(*it);
    return res;
  }
  template <typename R>
  R reduce(R u, function<R(R, T)> f) {
    for (auto it = begin(); it != end(); ++it) u = f(u, *it);
    return u;
  }
  template <typename U>
  Array<pair<T, U>> zip(const Array<U> &b) {
    assert(end() - begin() == b.end() - b.begin());
    Array<pair<T, U>> res;
    for (auto it = begin(); it != end(); ++it)
      res.push_back({*it, b[it - begin()]});
    return res;
  }
  Array<T> iota(T st) {
    Array<T> res(end() - begin());
    ::iota(res.begin(), res.end(), st);
    return res;
  }
};

signed main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  Array<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  Array<int> a = A.zip(Array<int>(N).iota(0))
                  .template map<int>([](pair<int, int> p) { return p.first - p.second; })
                  .select([](int x) { return 0 < x; });

  Array<int> dp(N, 0x3f3f3f3f);
  for (int v : a) *upper_bound(dp.begin(), dp.end(), v) = v;
  size_t lis = lower_bound(dp.begin(), dp.end(), 0x3f3f3f3f) - dp.begin();
  cout << N - lis << endl;
  
  return 0;
}
0