Submission #71767
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include<bits/stdc++.h> using namespace std; int main(){ int h,w; cin>>h>>w; int dp[h][w]={}; int a[h][w]; for ( int i=0;i<h;i++){ for ( int j=0;j<w;j++){ cin>>a[i][j]; } } for ( int i=h-1;i>=0;i--){ for ( int j=w-1;j>=0;j--){ if (i+1<h&&j+1<w){ dp[i][j]=max(dp[i+1][j],dp[i][j+1])+a[i][j]; } else if (i+1<h){ dp[i][j]=dp[i+1][j]+a[i][j]; } else if (j+1<w){ dp[i][j]=dp[i][j+1]+a[i][j]; } else { dp[i][j]+=a[i][j]; } } } cout<<dp[0][0]<< "\n" ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0910 - 百円以下の拾得物 |
ユーザー名 | ei2122 |
投稿日時 | 2022-08-10 22:23:16 |
言語 | C++17 |
状態 | Accepted |
得点 | 3 |
ソースコード長 | 677 Byte |
最大実行時間 | 178 ms |
最大メモリ使用量 | 8408 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 3 / 3 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 34 ms | 604 KB |
1
|
in02.txt | AC | 18 ms | 580 KB |
1
|
in03.txt | AC | 26 ms | 556 KB |
1
|
in04.txt | AC | 18 ms | 400 KB |
1
|
in05.txt | AC | 21 ms | 628 KB |
1
|
in06.txt | AC | 154 ms | 8408 KB |
1
|
in07.txt | AC | 155 ms | 8380 KB |
1
|
in08.txt | AC | 178 ms | 8228 KB |
1
|
in09.txt | AC | 170 ms | 8328 KB |
1
|
in10.txt | AC | 24 ms | 488 KB |
1
|
in11.txt | AC | 117 ms | 5484 KB |
1
|
sample_in_1.txt | AC | 18 ms | 428 KB |
1
|
sample_in_2.txt | AC | 21 ms | 524 KB |
1
|