結果
問題 |
No.2095 High Rise
|
ユーザー |
![]() |
提出日時 | 2022-10-12 22:17:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 889 ms / 2,000 ms |
コード長 | 728 bytes |
コンパイル時間 | 875 ms |
コンパイル使用メモリ | 97,828 KB |
最終ジャッジ日時 | 2025-02-08 02:15:36 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:22:21: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=] 22 | scanf("%d",&a[i][j]); | ~^ ~~~~~~~~ | | | | | long long int* | int* | %lld main.cpp:22:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d",&a[i][j]); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <vector> #include <queue> #include <set> #include <numeric> #include <cmath> #define ll long long using namespace std; // link : // category : int main() { int n,m; cin>>n>>m; ll a[n][m]={}, dp[n][m]={}; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ scanf("%d",&a[i][j]); if (i==0) dp[i][j]=a[i][j]; } for(int i=1;i<n;i++){ for(int j=0;j<m;j++){ dp[i][j]=min(dp[i-1][j]+a[i][j],*min_element(dp[i-1],dp[i-1]+m)+a[i-1][j]+a[i][j]); } } for(int j=0;j<m;j++){ dp[0][j]=0; } cout<<*min_element(dp[n-1],dp[n-1]+m)<<endl; return 0; }