結果

問題 No.711 競技レーティング単調増加
コンテスト
ユーザー WutongDeath
提出日時 2025-11-18 23:53:24
言語 C++14
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 21 ms / 2,000 ms
+ 334µs
コード長 544 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 323 ms
コンパイル使用メモリ 76,416 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-16 19:45:39
合計ジャッジ時間 2,962 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200010;

int n, a[N], dp[N], ans;

int main() {
    // freopen("score.in", "r", stdin);
    // freopen("score.out", "w", stdout);

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

    for (int i = 1; i <= n; ++i) {
        if (a[i] >= i) {
            int idx = upper_bound(dp + 1, dp + ans + 1, a[i] - i) - dp;
            dp[idx] = a[i] - i;
            ans = max(ans, idx);
        }
    }

    printf("%d\n", n - ans);

    return 0;
}
0