結果

問題 No.711 競技レーティング単調増加
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2018-07-01 08:53:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,034 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 173,652 KB
実行使用メモリ 9,024 KB
最終ジャッジ日時 2023-09-13 16:32:21
合計ジャッジ時間 4,527 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 30 ms
7,536 KB
testcase_31 AC 34 ms
7,820 KB
testcase_32 AC 36 ms
7,920 KB
testcase_33 AC 34 ms
8,848 KB
testcase_34 AC 33 ms
8,532 KB
testcase_35 AC 36 ms
9,024 KB
testcase_36 AC 26 ms
8,548 KB
testcase_37 AC 35 ms
8,280 KB
testcase_38 AC 29 ms
7,948 KB
testcase_39 AC 14 ms
5,808 KB
testcase_40 AC 19 ms
6,588 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 18 ms
6,420 KB
testcase_43 AC 25 ms
7,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------

// 前後に必ず番兵を用意すること
// 番兵は-1とINT_MAX/2-1を使う
#define rrep(i,a,b) for(int i=a;i>=b;i--)
struct LIS {
    vector<int>& v;
    vector<int> dp, id, ret, info;
    // info 1:unused 2:使っても良い 3:必ず使う
    int n;
    int lis;
    LIS(vector<int>& _v) : v(_v) {
        n = v.size();
        dp.resize(n, INT_MAX / 2);
        id.resize(n, 0);
        rep(i, 0, n-1) {
            // 狭義単調増加列
            //id[i] = lower_bound(dp.begin(), dp.end(), v[i]) - dp.begin();
            // 広義単調増加列
            id[i] = upper_bound(dp.begin(), dp.end(), v[i]) - dp.begin();
            dp[id[i]] = v[i];
        }
        int nl = *max_element(id.begin(), id.end());
        lis = nl;
        ret.resize(nl + 1, 0);
        rrep(i, n - 1, 0) if (id[i] == nl) ret[nl] = v[i], nl--;

        info.resize(n);
        vector<int> ma(n + 1), cnt(n);
        ma[lis] = INT_MAX / 2;
        rrep(i, n - 1, 0) {
            // 狭義単調増加列
            //if (ma[id[i] + 1] <= v[i]) info[i] = 1;
            // 広義単調増加列
            if (ma[id[i] + 1] < v[i]) info[i] = 1;

            else cnt[id[i]]++, ma[id[i]] = max(ma[id[i]], v[i]);
        }

        rrep(i, n - 1, 0) if (info[i] == 0 && cnt[id[i]] == 1) info[i] = 3;
        rep(i, 0, n) if (info[i] == 0) info[i] = 2;
    }
};

/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/






int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    vector<int> v;
    v.push_back(-inf);
    rep(i, 0, N) v.push_back(A[i] - i);
    v.push_back(inf);

    //fore(i, v) printf("%d ", i);
    //printf("\n");

    LIS lis(v);
    int ans = N - lis.lis;
    //cout << lis.lis << endl;
    cout << ans << endl;
}
0