Submission #44592


ソースコード

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
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int mon(int y,int x);
int h,w,a[1005][1005];
int memo[1005][1005];
int main(){
memset(memo,-1,sizeof(memo));
cin>>h>>w;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cin>>a[i][j];
}
}
cout<<mon(h-1,w-1)<<"\n";
return 0;
}
int mon(int y,int x){
if(memo[y][x]!=-1)return memo[y][x];
if(x==0 && y==0){
return a[y][x];
}
if(x==0){
return memo[y][x]=mon(y-1,x)+a[y][x];
}
if(y==0){
return memo[y][x]=mon(y,x-1)+a[y][x];
}
return memo[y][x]=max(mon(y-1,x),mon(y,x-1))+a[y][x];
}

ステータス

項目 データ
問題 0910 - 百円以下の拾得物
ユーザー名 ei1832
投稿日時 2018-11-06 18:15:45
言語 C++
状態 Accepted
得点 3
ソースコード長 634 Byte
最大実行時間 203 ms
最大メモリ使用量 8540 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 30 ms 4700 KB
1
in02.txt AC 29 ms 4676 KB
1
in03.txt AC 26 ms 4648 KB
1
in04.txt AC 26 ms 4616 KB
1
in05.txt AC 23 ms 4716 KB
1
in06.txt AC 159 ms 8528 KB
1
in07.txt AC 157 ms 8472 KB
1
in08.txt AC 189 ms 8540 KB
1
in09.txt AC 203 ms 8488 KB
1
in10.txt AC 26 ms 6636 KB
1
in11.txt AC 123 ms 7376 KB
1
sample_in_1.txt AC 34 ms 4564 KB
1
sample_in_2.txt AC 20 ms 4536 KB
1