結果

問題 No.2095 High Rise
ユーザー Nzt3Nzt3
提出日時 2022-12-23 02:22:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 2,383 ms
コンパイル使用メモリ 206,952 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-04-29 04:09:45
合計ジャッジ時間 4,261 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 15 ms
5,376 KB
testcase_18 AC 11 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 16 ms
5,376 KB
testcase_21 AC 30 ms
5,376 KB
testcase_22 AC 120 ms
7,168 KB
testcase_23 AC 121 ms
7,168 KB
testcase_24 AC 121 ms
7,168 KB
testcase_25 AC 116 ms
7,168 KB
testcase_26 AC 122 ms
7,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0