結果

問題 No.2095 High Rise
ユーザー baLoon8128baLoon8128
提出日時 2022-10-07 21:52:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 4,177 ms
コンパイル使用メモリ 230,712 KB
実行使用メモリ 14,988 KB
最終ジャッジ日時 2023-09-03 01:33:49
合計ジャッジ時間 8,192 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 43 ms
4,964 KB
testcase_18 AC 30 ms
4,380 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 47 ms
4,380 KB
testcase_21 AC 88 ms
5,668 KB
testcase_22 AC 371 ms
14,928 KB
testcase_23 AC 372 ms
14,908 KB
testcase_24 AC 373 ms
14,948 KB
testcase_25 AC 372 ms
14,988 KB
testcase_26 AC 372 ms
14,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i)

int main() {
    int n, m;
    cin >> n >> m;
    vvi a(n, vi(m));
    rep(i, n) rep(j, m) cin >> a[i][j];
    if (n == 1) {
        cout << 0 << endl;
    } else {
        vector<vector<ll>> dp(n + 1, vector<ll>(m));
        rep(i, n) {
            rep(j, m) dp[i + 1][j] = dp[i][j] + a[i][j];
            ll mi = *min_element(dp[i + 1].begin(), dp[i + 1].end());
            rep(j, m) dp[i + 1][j] = min(dp[i + 1][j], mi + a[i][j]);
        }
        ll ret = *min_element(dp[n].begin(), dp[n].end());
        cout << ret << endl;
    }
    return 0;
}
0