結果
| 問題 |
No.2095 High Rise
|
| コンテスト | |
| ユーザー |
shkiiii_
|
| 提出日時 | 2022-10-07 22:46:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 351 ms / 2,000 ms |
| コード長 | 849 bytes |
| コンパイル時間 | 1,409 ms |
| コンパイル使用メモリ | 172,636 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-06-12 20:04:24 |
| 合計ジャッジ時間 | 4,584 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#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;
}
shkiiii_