結果

問題 No.2095 High Rise
ユーザー kokatsukokatsu
提出日時 2022-10-23 18:06:41
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 5,526 ms
コンパイル使用メモリ 204,284 KB
実行使用メモリ 24,472 KB
最終ジャッジ日時 2023-09-04 18:41:31
合計ジャッジ時間 6,334 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 23 ms
9,232 KB
testcase_18 AC 16 ms
6,896 KB
testcase_19 AC 5 ms
4,592 KB
testcase_20 AC 24 ms
12,032 KB
testcase_21 AC 43 ms
12,580 KB
testcase_22 AC 173 ms
23,360 KB
testcase_23 AC 173 ms
24,416 KB
testcase_24 AC 174 ms
24,472 KB
testcase_25 AC 173 ms
23,432 KB
testcase_26 AC 174 ms
24,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    long N, M;
    readf("%d %d\n", N, M);

    auto A = new long[][](N);
    foreach (i; 0 .. N) A[i] = readln.chomp.split.to!(long[]);

    if (N == 1) {
        writeln(0);
        return;
    }

    long res = A[0].minElement;

    auto dp = new long[][](N, M);
    dp[0][] = A[0][];
    foreach (i; 1 .. N) {
        foreach (j; 0 .. M) {
            dp[i][j] = A[i][j] + min(dp[i-1][j], res+A[i-1][j]);
        }

        res = dp[i].minElement;
    }

    res.writeln;
}
0