結果

問題 No.2095 High Rise
ユーザー ruthenruthen
提出日時 2022-10-07 23:25:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 204,020 KB
実行使用メモリ 11,032 KB
最終ジャッジ日時 2023-09-03 15:49:47
合計ジャッジ時間 4,695 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 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 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 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,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 16 ms
4,380 KB
testcase_18 AC 11 ms
4,376 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 17 ms
4,376 KB
testcase_21 AC 31 ms
4,804 KB
testcase_22 AC 126 ms
10,960 KB
testcase_23 AC 127 ms
11,024 KB
testcase_24 AC 126 ms
10,960 KB
testcase_25 AC 126 ms
11,032 KB
testcase_26 AC 125 ms
11,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    V<V<ll>> A(N, V<ll>(M));
    rep(i, N) rep(j, M) cin >> A[i][j];
    if (N == 1) {
        cout << 0 << '\n';
        return 0;
    }
    const ll INF = 1LL << 60;
    V<ll> dp(M, INF);
    rep(i, M) dp[i] = A[0][i];
    for (int i = 1; i < N; i++) {
        V<ll> np(M, INF);
        ll mn = *min_element(dp.begin(), dp.end());
        show(mn);
        rep(j, M) np[j] = mn + A[i - 1][j] + A[i][j];
        rep(j, M) np[j] = min(np[j], dp[j] + A[i][j]);
        swap(dp, np);
        show(dp);
    }
    ll ans = *min_element(dp.begin(), dp.end());
    cout << ans << '\n';
    return 0;
}
0