結果

問題 No.2095 High Rise
ユーザー _yurimoir_yurimoir
提出日時 2022-10-08 09:18:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 386 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 3,951 ms
コンパイル使用メモリ 248,640 KB
実行使用メモリ 18,628 KB
最終ジャッジ日時 2023-09-04 08:23:32
合計ジャッジ時間 7,824 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 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,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 45 ms
5,056 KB
testcase_18 AC 30 ms
4,660 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 48 ms
5,108 KB
testcase_21 AC 91 ms
6,668 KB
testcase_22 AC 386 ms
18,544 KB
testcase_23 AC 386 ms
18,544 KB
testcase_24 AC 386 ms
18,628 KB
testcase_25 AC 385 ms
18,604 KB
testcase_26 AC 386 ms
18,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,m;
    cin>>n>>m;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    vector<vector<ll>> a(n,vector<ll>(m,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    vector<vector<ll>> dp(n,vector<ll>(m,0));
    for(int i=0;i<m;i++){
        dp[0][i]=a[0][i];
    }
    for(int i=1;i<n;i++){
        ll mn=*min_element(dp[i-1].begin(),dp[i-1].end());
        for(int j=0;j<m;j++){
            dp[i][j]=min(dp[i-1][j]+a[i][j],mn+a[i-1][j]+a[i][j]);
        }
    }
    ll ans=1e18;
    for(int i=0;i<m;i++){
        ans=min(ans,dp[n-1][i]);
    }
    cout<<ans<<endl;
}
0