結果

問題 No.2095 High Rise
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-05 18:24:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 385 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 111,388 KB
実行使用メモリ 19,100 KB
最終ジャッジ日時 2023-08-15 00:42:53
合計ジャッジ時間 6,328 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 45 ms
5,376 KB
testcase_18 AC 30 ms
4,636 KB
testcase_19 AC 8 ms
4,376 KB
testcase_20 AC 48 ms
4,996 KB
testcase_21 AC 92 ms
6,848 KB
testcase_22 AC 382 ms
19,100 KB
testcase_23 AC 382 ms
18,608 KB
testcase_24 AC 383 ms
18,924 KB
testcase_25 AC 383 ms
18,600 KB
testcase_26 AC 385 ms
18,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll N, M, mi=0, mi2;
    cin >> N >> M;
    vector<vector<ll>> dp(N+1, vector<ll>(M+1, 1e18)), A(N+1, vector<ll>(M+1));
    for (int i=1; i<=N; i++){
        for (int j=1; j<=M; j++) cin >> A[i][j];
    }
    if (N == 1){
        cout << 0 << endl;
        return 0;
    }

    for (int i=2; i<=N; i++){
        mi2 = 1e18;
        for (int j=1; j<=M; j++){
            dp[i][j] = min(dp[i-1][j]+A[i][j], mi+A[i][j]+A[i-1][j]);
            mi2 = min(mi2, dp[i][j]);
        }
        swap(mi2, mi);
    }

    cout << mi << endl;

    return 0;
}
0