結果

問題 No.2095 High Rise
ユーザー t98slidert98slider
提出日時 2022-10-07 22:59:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 170,540 KB
実行使用メモリ 18,888 KB
最終ジャッジ日時 2023-09-03 14:54:20
合計ジャッジ時間 4,506 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 17 ms
4,844 KB
testcase_18 AC 11 ms
4,384 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 17 ms
4,916 KB
testcase_21 AC 33 ms
6,752 KB
testcase_22 AC 130 ms
18,888 KB
testcase_23 AC 132 ms
18,828 KB
testcase_24 AC 132 ms
18,816 KB
testcase_25 AC 132 ms
18,832 KB
testcase_26 AC 132 ms
18,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    if(h == 1){
        cout << 0 << '\n';
        return 0;
    }
    vector<vector<ll>> A(h, vector<ll>(w)), dp(h, vector<ll>(w));
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            cin >> A[y][x];
        }
    }
    dp[0] = A[0];
    for(int y = 0; y + 1 < h; y++){
        ll v = *min_element(dp[y].begin(), dp[y].end());
        for(int x = 0; x < w; x++){
            dp[y + 1][x] = min(dp[y][x] + A[y + 1][x], A[y][x] + A[y + 1][x] + v);
        }
    }
    cout << *min_element(dp[h - 1].begin(), dp[h - 1].end()) << '\n';
}
0