結果

問題 No.2095 High Rise
ユーザー shkiiii_shkiiii_
提出日時 2022-10-07 22:46:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 849 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 171,132 KB
実行使用メモリ 11,188 KB
最終ジャッジ日時 2023-09-03 14:22:51
合計ジャッジ時間 6,009 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,384 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 3 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 44 ms
4,380 KB
testcase_18 AC 30 ms
4,376 KB
testcase_19 AC 8 ms
4,376 KB
testcase_20 AC 48 ms
4,380 KB
testcase_21 AC 90 ms
5,388 KB
testcase_22 AC 375 ms
10,928 KB
testcase_23 AC 380 ms
10,924 KB
testcase_24 AC 378 ms
11,188 KB
testcase_25 AC 379 ms
10,860 KB
testcase_26 AC 378 ms
11,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
// #define MOD 998244353


int main(){
  
  int n,m;
  cin >> n >> m;
  vector<vector<ll>> a(n,vector<ll>(m));
  rep(i,n)rep(j,m)cin >> a[i][j];
  if(n == 1){
    cout << "0\n";
    return 0;
  }
  vector<ll> dp(m);
  rep(i,m)dp[i] = a[0][i];
  for(int i = 1;i < n;i++){
    vector<ll> DP(m);
    ll k = *min_element(ALL(dp));
    rep(j,m)DP[j] = min(k + a[i][j] + a[i-1][j],dp[j] + a[i][j]);
    swap(dp,DP);
  }
  cout << *min_element(ALL(dp)) << "\n";
  

  return 0;
}
0