Submission #61426


ソースコード

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
#include<bits/stdc++.h>
#define lol long long
using namespace std;
lol mem[1010][1010];
int a[1010][1010];
lol dp(int x, int y);
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int h,w;
cin >>h>>w;
memset(mem,-1,sizeof(mem));
for(int i=1;i<=h;i++)
for(int j=1;j<=w;j++) cin >>a[i][j];
cout <<dp(h,w)<<'\n';
return (0);
}
lol dp(int x,int y){
if(x<=0||y<=0) return 0;
if(mem[x][y]!=-1) return mem[x][y];
lol sum;
sum=a[x][y]+max(dp(x-1,y),dp(x,y-1));
return (mem[x][y]=sum);
}

ステータス

項目 データ
問題 0910 - 百円以下の拾得物
ユーザー名 ei1923
投稿日時 2020-07-29 17:58:59
言語 C++17
状態 Accepted
得点 3
ソースコード長 550 Byte
最大実行時間 78 ms
最大メモリ使用量 12680 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 22 ms 10588 KB
1
in02.txt AC 16 ms 10464 KB
1
in03.txt AC 28 ms 10452 KB
1
in04.txt AC 20 ms 10316 KB
1
in05.txt AC 23 ms 10460 KB
1
in06.txt AC 71 ms 12532 KB
1
in07.txt AC 78 ms 12608 KB
1
in08.txt AC 75 ms 12680 KB
1
in09.txt AC 74 ms 12496 KB
1
in10.txt AC 23 ms 10772 KB
1
in11.txt AC 56 ms 12604 KB
1
sample_in_1.txt AC 22 ms 10520 KB
1
sample_in_2.txt AC 20 ms 10528 KB
1