Submission #56183


ソースコード

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
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b;
lol i[1001][1111];
lol ans[1001][1001];
lol dp(int x,int y){
if(x==0&&y==0) return i[0][0];
if(ans[x][y]!=-1) return ans[x][y];
if(x==0) return ans[x][y]=i[x][y]+dp(x,y-1);
if(y==0) return ans[x][y]=i[x][y]+dp(x-1,y);
return ans[x][y]=i[x][y]+max(dp(x-1,y),dp(x,y-1));
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
lol c=1,d=1,e=0,f=0,g=0,h=0;
string s,w;
cin >>a>>b;
for(int n=0;n<a;n++){
for(int m=0;m<b;m++) cin >>i[n][m];
}
memset(ans,-1,sizeof(ans));
cout <<dp(a-1,b-1)<<'\n';
return (0);
}

ステータス

項目 データ
問題 0910 - 百円以下の拾得物
ユーザー名 ei1923
投稿日時 2019-11-05 18:46:20
言語 C++14
状態 Accepted
得点 3
ソースコード長 836 Byte
最大実行時間 157 ms
最大メモリ使用量 20008 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.txt AC 29 ms 8796 KB
1
in02.txt AC 26 ms 8888 KB
1
in03.txt AC 18 ms 8724 KB
1
in04.txt AC 22 ms 8812 KB
1
in05.txt AC 18 ms 8768 KB
1
in06.txt AC 118 ms 17816 KB
1
in07.txt AC 119 ms 18540 KB
1
in08.txt AC 146 ms 19144 KB
1
in09.txt AC 157 ms 20008 KB
1
in10.txt AC 47 ms 13696 KB
1
in11.txt AC 95 ms 17992 KB
1
sample_in_1.txt AC 22 ms 11712 KB
1
sample_in_2.txt AC 22 ms 11792 KB
1