結果
| 問題 |
No.2095 High Rise
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-23 02:22:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 2,000 ms |
| コード長 | 601 bytes |
| コンパイル時間 | 1,897 ms |
| コンパイル使用メモリ | 200,348 KB |
| 最終ジャッジ日時 | 2025-02-09 18:51:19 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
if(N==1){
cout<<"0\n";
return 0;
}
vector<vector<int>>A(N,vector<int>(M));
for(int i=0;i<N;i++){
for(int j=0;j<M;j++)cin>>A[i][j];
}
vector<long long>d1(M),d2(M);
for(int i=0;i<M;i++){
d1[i]=A[0][i];
}
for(int i=0;i<N-1;i++){
long long m=*min_element(d1.begin(),d1.end());
for(int j=0;j<M;j++){
d2[j]=min(d1[j]+A[i+1][j],m+A[i][j]+A[i+1][j]);
}
swap(d1,d2);
}
cout<<*min_element(d1.begin(),d1.end())<<'\n';
}