Advertisement
Guest User

za tumi chaveto 109272472

a guest
Mar 24th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. long long pole[10][10];
  4. long long maxSubrano(long long sx, long long sy) {
  5. long long mezhdinna;
  6. if (sx==0 && sy==0) {
  7. return pole[sx][sy];
  8. }
  9. if (sx==0) {
  10. return pole[sx][sy]+maxSubrano(sx,sy-1);
  11. }
  12. if (sy==0) {
  13. return pole[sx][sy]+maxSubrano(sx-1,sy);
  14. }
  15. if (maxSubrano(sx-1,sy)>maxSubrano(sx,sy-1)) {
  16. return maxSubrano(sx-1,sy)+pole[sx][sy];
  17. }else{
  18. return maxSubrano(sx,sy-1)+pole[sx][sy];
  19. }
  20. }
  21. int main () {
  22. long long razmerX,razmerY,x,y;
  23. cin >> razmerX >> razmerY;
  24. for (y=0;y<razmerY;y++) {
  25. for (x=0;x<razmerX;x++) {
  26. cin >> pole[x][y];
  27. }
  28. }
  29. cout << maxSubrano(razmerX-1,razmerY-1);
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement