結果

問題 No.711 競技レーティング単調増加
ユーザー nebukuro09nebukuro09
提出日時 2018-07-10 14:22:12
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 2,993 ms
コンパイル使用メモリ 113,004 KB
実行使用メモリ 32,384 KB
最終ジャッジ日時 2023-09-03 20:39:41
合計ジャッジ時間 4,950 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 78 ms
14,148 KB
testcase_19 AC 77 ms
15,860 KB
testcase_20 AC 81 ms
14,988 KB
testcase_21 AC 83 ms
14,676 KB
testcase_22 AC 79 ms
13,984 KB
testcase_23 AC 92 ms
19,944 KB
testcase_24 AC 89 ms
18,304 KB
testcase_25 AC 73 ms
13,572 KB
testcase_26 AC 79 ms
14,320 KB
testcase_27 AC 74 ms
13,668 KB
testcase_28 AC 24 ms
7,820 KB
testcase_29 AC 28 ms
9,404 KB
testcase_30 AC 99 ms
18,164 KB
testcase_31 AC 128 ms
29,160 KB
testcase_32 AC 137 ms
30,536 KB
testcase_33 AC 83 ms
18,336 KB
testcase_34 AC 71 ms
16,544 KB
testcase_35 AC 87 ms
18,884 KB
testcase_36 AC 18 ms
8,952 KB
testcase_37 AC 121 ms
32,384 KB
testcase_38 AC 102 ms
27,220 KB
testcase_39 AC 30 ms
11,596 KB
testcase_40 AC 40 ms
11,996 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 32 ms
7,596 KB
testcase_43 AC 84 ms
25,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable int INF = 1 << 29;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    long[] B;
    int ans = 0;

    foreach (i; 0..N) {
        if (A[i] - i > 0) {
            B ~= A[i] - i;
        } else {
            ans += 1;
        }
    }
    
    N = B.length.to!int;
    
    auto C = B.dup;
    C = C.sort().uniq().array;
    int[long] comp;
    foreach (i; 0..C.length.to!int) comp[C[i]] = i;
    
    auto dp = new int[](N+1);
    fill(dp, INF);
    dp[0] = -1;

    foreach (i; 0..N) {
        int b = comp[B[i]];
        int lb = dp.assumeSorted.lowerBound(b+1).length.to!int;
        dp[lb] = b;
    }


    int tmp = 0;
    foreach (i; 0..N+1) if (dp[i] < INF) tmp = N - i;
    ans += tmp;

    ans.writeln;
}
0