Advertisement
Estera

Untitled

Jan 17th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("cladire2.in");
  5. ofstream fout("cladire2.out");
  6. int n,a[101][101],b[101][101];
  7. struct camera{int l,c;}v[101];
  8. int main()
  9. {
  10. fin>>n;
  11. for(int i=1;i<=n;i++)
  12. for(int j=1;j<=m;j++)
  13. fin>>a[i][j];
  14. b[1][1]=a[1][1];
  15. v[1].l=1;
  16. v[2].c=1;
  17. for(int j=2;j<=n;j++)
  18. b[1][j]=b[1][j-1]+a[1][j];
  19. for(int i=2;i<=n;i++)
  20. b[i][1]=b[i-1][1]+a[i][1];
  21. for(int i=2;i<=n;i++)
  22. for(int j=2;j<=m;j++)
  23. b[i][j]=max(b[i-1][j],b[i][j-1])+a[i][j];
  24. fout<<b[n][m];
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement