結果

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

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 200010, INF = 0x3f3f3f3f;

int n, f[N], ma;

int main() {
    scanf("%d", &n);
    memset(f, 0x3f, sizeof(f));
    ma = 0;
    for (int i = 1, x, idx; i <= n; ++i) {
        scanf("%d", &x);
        if (x >= i) {
            idx = upper_bound(f + 1, f + n + 1, x - i) - f;
            f[idx] = x - i;
            ma = max(ma, idx);
        }
    }
    printf("%d\n", n - ma);
    
    return 0;
}
0