-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx.cpp
More file actions
40 lines (31 loc) · 636 Bytes
/
x.cpp
File metadata and controls
40 lines (31 loc) · 636 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
#include <bits/stdc++.h>
using namespace std;
int n, m;
int arr[11][11];
int maxmumPath(int start, int end)
{
if (start == n - 1 && end == m - 1)
{
return arr[start][end];
}
else if (start == n + 1 || end == m + 1)
{
return -1000000;
}
int right = maxmumPath(start, end + 1);
int down = maxmumPath(start + 1, end);
return arr[start][end] + max(right, down);
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> arr[i][j];
}
}
cout << maxmumPath(0, 0) << endl;
return 0;
}