Submission #61827


ソースコード

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
#include<iostream>
#include<cstring>
int a[1001][1001];
long long mem[1001][1001];
long long dp(int x,int y);
using namespace std;
int main(){
int h,w;
cin>>h>>w;
int i,j;
//-1ですべて初期化
memset(mem,-1,sizeof(mem));
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
cin>>a[i][j];
}
}
cout<<dp(h,w)<<"\n";
return 0;
}
long long dp(int x,int y){
if(x<=0||y<=0){
return 0;
}
if(mem[x][y]!=-1){
return mem[x][y];
}
int sum=0;
sum=a[x][y]+max(dp(x-1,y),dp(x,y-1));
mem[x][y]=sum;
return sum;
}

ステータス

項目 データ
問題 0910 - 百円以下の拾得物
ユーザー名 ei2011
投稿日時 2020-08-07 12:20:56
言語 C++17
状態 Accepted
得点 3
ソースコード長 644 Byte
最大実行時間 177 ms
最大メモリ使用量 12368 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 24 ms 8796 KB
1
in02.txt AC 29 ms 8644 KB
1
in03.txt AC 18 ms 8752 KB
1
in04.txt AC 20 ms 8732 KB
1
in05.txt AC 16 ms 8708 KB
1
in06.txt AC 156 ms 12268 KB
1
in07.txt AC 164 ms 12320 KB
1
in08.txt AC 177 ms 12368 KB
1
in09.txt AC 169 ms 12288 KB
1
in10.txt AC 22 ms 10804 KB
1
in11.txt AC 121 ms 11288 KB
1
sample_in_1.txt AC 20 ms 8824 KB
1
sample_in_2.txt AC 23 ms 8804 KB
1