結果

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

ソースコード

diff #

#include <iostream>
#include <cstring>

using namespace std;

const int N = 200010, INF = 0x3f3f3f3f;

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

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

    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for (int i = 1, pre = 0; i <= n; ++i) {
        if (dp[pre] != a[i] - 1) {
            ++pre;
        }
        for (int j = pre; j >= 0; --j) {
            if (j == i) {
                dp[j] = i;
                ans = i;
            } else {
                dp[j] = a[i] > dp[j] ? a[i] : INF;
                if (j >= 1) dp[j] = min(dp[j], dp[j - 1] + 1);
            }
            if (dp[j] != INF) {
                ans = j;
            } else {
                break;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}
0