結果

問題 No.711 競技レーティング単調増加
コンテスト
ユーザー 梧桐
提出日時 2025-11-18 23:53:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 62,904 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-18 23:53:28
合計ジャッジ時間 4,114 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:15:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
      |                                  ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#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