結果

問題 No.711 競技レーティング単調増加
ユーザー kimiyukikimiyuki
提出日時 2018-06-30 02:07:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 2,141 ms
コンパイル使用メモリ 202,172 KB
実行使用メモリ 6,092 KB
最終ジャッジ日時 2023-09-13 16:07:41
合計ジャッジ時間 5,690 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 53 ms
4,380 KB
testcase_19 AC 51 ms
4,396 KB
testcase_20 AC 54 ms
4,504 KB
testcase_21 AC 57 ms
4,380 KB
testcase_22 AC 52 ms
4,380 KB
testcase_23 AC 59 ms
4,552 KB
testcase_24 AC 59 ms
4,504 KB
testcase_25 AC 49 ms
4,376 KB
testcase_26 AC 53 ms
4,432 KB
testcase_27 AC 49 ms
4,440 KB
testcase_28 AC 40 ms
4,380 KB
testcase_29 AC 48 ms
4,376 KB
testcase_30 AC 61 ms
4,584 KB
testcase_31 AC 75 ms
4,664 KB
testcase_32 AC 78 ms
5,020 KB
testcase_33 AC 70 ms
5,580 KB
testcase_34 AC 64 ms
5,200 KB
testcase_35 AC 72 ms
6,092 KB
testcase_36 AC 29 ms
4,376 KB
testcase_37 AC 78 ms
4,856 KB
testcase_38 AC 54 ms
4,644 KB
testcase_39 AC 28 ms
4,380 KB
testcase_40 AC 36 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 31 ms
4,376 KB
testcase_43 AC 45 ms
5,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template <typename T>
vector<T> longest_weak_increasing_subsequence(vector<T> const & xs) {
    vector<T> l;  // l[i] is the last element of the increasing subsequence whose length is i + 1
    for (auto && x : xs) {
        auto it = upper_bound(l.begin(), l.end(), x);
        if (it == l.end()) {
            l.push_back(x);
        } else {
            *it = x;
        }
    }
    return l;
}

int main() {
    // input
    int n; cin >> n;
    vector<int> a(n);
    REP (i, n) cin >> a[i];

    // solve
    vector<int> b;
    REP (i, n) {
        int b_i = a[i] - i;
        if (b_i >= 1) b.push_back(b_i);
    }
    int answer = n - longest_weak_increasing_subsequence(b).size();

    // output
    cout << answer << endl;
    return 0;
}
0