daily pastebin goal
17%
SHARE
TWEET

za tumi chaveto 109272472

a guest Mar 24th, 2019 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top