結果
問題 | No.2095 High Rise |
ユーザー | otoshigo |
提出日時 | 2022-10-07 21:46:50 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 126 ms / 2,000 ms |
コード長 | 872 bytes |
コンパイル時間 | 1,951 ms |
コンパイル使用メモリ | 199,640 KB |
実行使用メモリ | 19,372 KB |
最終ジャッジ日時 | 2023-09-03 01:19:29 |
合計ジャッジ時間 | 4,873 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,592 KB |
testcase_01 | AC | 2 ms
5,380 KB |
testcase_02 | AC | 2 ms
5,440 KB |
testcase_03 | AC | 2 ms
5,400 KB |
testcase_04 | AC | 2 ms
5,440 KB |
testcase_05 | AC | 2 ms
5,432 KB |
testcase_06 | AC | 2 ms
5,456 KB |
testcase_07 | AC | 2 ms
5,380 KB |
testcase_08 | AC | 2 ms
5,428 KB |
testcase_09 | AC | 2 ms
5,404 KB |
testcase_10 | AC | 2 ms
5,500 KB |
testcase_11 | AC | 2 ms
5,424 KB |
testcase_12 | AC | 3 ms
7,832 KB |
testcase_13 | AC | 3 ms
7,708 KB |
testcase_14 | AC | 3 ms
7,848 KB |
testcase_15 | AC | 3 ms
7,728 KB |
testcase_16 | AC | 3 ms
5,524 KB |
testcase_17 | AC | 18 ms
13,224 KB |
testcase_18 | AC | 13 ms
12,960 KB |
testcase_19 | AC | 5 ms
8,164 KB |
testcase_20 | AC | 18 ms
8,988 KB |
testcase_21 | AC | 33 ms
11,556 KB |
testcase_22 | AC | 126 ms
19,252 KB |
testcase_23 | AC | 126 ms
19,244 KB |
testcase_24 | AC | 126 ms
19,248 KB |
testcase_25 | AC | 126 ms
19,312 KB |
testcase_26 | AC | 126 ms
19,372 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for (int i = 0; i < n; i++) #define rrep(i,n) for (int i = (n) - 1; i >= 0; i--) int n,m; ll A[1010][1010],dp[1010][1010],L[1010],R[1010]; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cin>>n>>m; rep(i,n)rep(j,m)cin>>A[i][j]; if(n==1){ cout<<0<<"\n"; return 0; } rep(i,n)rep(j,m)dp[i][j]=1LL<<60; rep(i,m)dp[0][i]=A[0][i]; rep(i,n-1){ L[0]=1LL<<60;; rep(j,m-1){ L[j+1]=min(L[j],dp[i][j]); } R[m-1]=1LL<<60; rrep(j,m-1){ R[j]=min(R[j+1],dp[i][j+1]); } rep(j,m){ dp[i+1][j]=min(dp[i][j]+A[i+1][j],min(L[j],R[j])+A[i][j]+A[i+1][j]); } } ll ans=1LL<<60; rep(i,m)ans=min(ans,dp[n-1][i]); cout<<ans<<"\n"; }