-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_11048.cpp
More file actions
55 lines (44 loc) · 833 Bytes
/
Copy pathBOJ_11048.cpp
File metadata and controls
55 lines (44 loc) · 833 Bytes
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#define endl "\n"
#define MAX 1010
using namespace std;
int N, M;
int MAP[MAX][MAX];
int Candy[MAX][MAX];
int Max(int A, int B) { if (A > B) return A; return B; }
void Input()
{
cin >> N >> M;
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= M; j++)
{
cin >> MAP[i][j];
}
}
}
void Solution()
{
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= M; j++)
{
Candy[i][j] = Max(Max(Candy[i - 1][j], Candy[i][j - 1]), Candy[i - 1][j - 1]) + MAP[i][j];
}
}
cout << Candy[N][M] << endl;
}
void Solve()
{
Input();
Solution();
}
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("Input.txt", "r", stdin);
Solve();
return 0;
}