Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <string>
  4. #include <set>
  5. #include <map>
  6. #include <algorithm>
  7. #include <vector>
  8. using namespace std;
  9. int main()
  10. {
  11. long n, m;
  12. cin >> n >> m;
  13. vector<vector<long> > a(n + 1, vector<long> (m + 1, 0));
  14. for(long i = 1; i <= n; i++) {
  15. for(long j = 1; j <= m; j++) {
  16. cin >> a[i][j];
  17. }
  18. }
  19. for(long i = 1; i <= n; i++) {
  20. for(long j = 1; j <= m; j++) {
  21. a[i][j] += max(a[i][j - 1], max(a[i - 1][j - 1], a[i - 1][j]));
  22. }
  23. }
  24. cout << a[n][m];
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement