Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long long pole[10][10];
- long long maxSubrano(long long sx, long long sy) {
- long long mezhdinna;
- if (sx==0 && sy==0) {
- return pole[sx][sy];
- }
- if (sx==0) {
- return pole[sx][sy]+maxSubrano(sx,sy-1);
- }
- if (sy==0) {
- return pole[sx][sy]+maxSubrano(sx-1,sy);
- }
- if (maxSubrano(sx-1,sy)>maxSubrano(sx,sy-1)) {
- return maxSubrano(sx-1,sy)+pole[sx][sy];
- }else{
- return maxSubrano(sx,sy-1)+pole[sx][sy];
- }
- }
- int main () {
- long long razmerX,razmerY,x,y;
- cin >> razmerX >> razmerY;
- for (y=0;y<razmerY;y++) {
- for (x=0;x<razmerX;x++) {
- cin >> pole[x][y];
- }
- }
- cout << maxSubrano(razmerX-1,razmerY-1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement