Submission #71548


ソースコード

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
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define ll long long
#define ptn(v) next_permutation(v.begin(), v.end())
#define fixed(v) fixed << setprecision(v)
#define total(n) (n * (n + 1) / 2)
#define lcm(a, b) ((a) * (b) / __gcd(a, b))
// binery_search(all(v),key) = keyがあるかないかをboolで返す
// lower_bound(all(v),key) = key以上のイテレーターを返す(一番左)
// upper_bound(all(v),key) = keyより大きい要素のイテレーターを返す
// 最小値=max_element(v.begin(),v.end());
// 最大値=min_element(v.begin(),v.end());
using namespace std;
int main(){
int h,w;
cin>>h>>w;
vector<vector<ll>> dp(h+1,vector<ll>(w,0));
vector<vector<ll>> vv(h,vector<ll>(w));
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cin>>vv[i][j];
}
}
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(i==0&&j==0){
dp[i][j]=vv[i][j];
} else if(i==0){
dp[i][j]=dp[i][j-1]+vv[i][j];
} else if(j==0){
dp[i][j]=dp[i-1][j]+vv[i][j];
} else {
dp[i][j]=max(dp[i-1][j],dp[i][j-1])+vv[i][j];
}
}
}
cout<<dp[h-1][w-1]<<endl;
return (0);
}

ステータス

項目 データ
問題 0910 - 百円以下の拾得物
ユーザー名 ei2134
投稿日時 2022-07-27 13:56:57
言語 C++17
状態 Accepted
得点 3
ソースコード長 1304 Byte
最大実行時間 179 ms
最大メモリ使用量 16316 KB

セット

セット 得点 Cases
1 ALL 3 / 3 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 28 ms 604 KB
1
in02.txt AC 22 ms 700 KB
1
in03.txt AC 17 ms 540 KB
1
in04.txt AC 25 ms 500 KB
1
in05.txt AC 24 ms 600 KB
1
in06.txt AC 168 ms 16316 KB
1
in07.txt AC 168 ms 16316 KB
1
in08.txt AC 171 ms 16184 KB
1
in09.txt AC 179 ms 16308 KB
1
in10.txt AC 21 ms 812 KB
1
in11.txt AC 120 ms 10680 KB
1
sample_in_1.txt AC 21 ms 512 KB
1
sample_in_2.txt AC 19 ms 484 KB
1